diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-07-11 18:26:01 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-07-11 18:26:01 -0400 |
commit | 823ba01fc07751200c43e45733925a98b73eac3a (patch) | |
tree | c84853512445f6f56aeb0fcf8f9207222e9c80c0 /fs/ext4 | |
parent | 598dbdf2433cad55bd44d923f67a053871e3eabf (diff) |
ext4: fix a race which could leak memory in ext4_groupinfo_create_slab()
In ext4_groupinfo_create_slab, we create ext4_groupinfo_caches within
ext4_grpinfo_slab_create_mutex, but set it outside the lock, and there
does exist some case that we may create it twice and causes a memory
leak. So set it before we call mutex_unlock.
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/mballoc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 04a3d92aafb4..2b9a71b99b2b 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2404,14 +2404,14 @@ static int ext4_groupinfo_create_slab(size_t size) | |||
2404 | slab_size, 0, SLAB_RECLAIM_ACCOUNT, | 2404 | slab_size, 0, SLAB_RECLAIM_ACCOUNT, |
2405 | NULL); | 2405 | NULL); |
2406 | 2406 | ||
2407 | ext4_groupinfo_caches[cache_index] = cachep; | ||
2408 | |||
2407 | mutex_unlock(&ext4_grpinfo_slab_create_mutex); | 2409 | mutex_unlock(&ext4_grpinfo_slab_create_mutex); |
2408 | if (!cachep) { | 2410 | if (!cachep) { |
2409 | printk(KERN_EMERG "EXT4: no memory for groupinfo slab cache\n"); | 2411 | printk(KERN_EMERG "EXT4: no memory for groupinfo slab cache\n"); |
2410 | return -ENOMEM; | 2412 | return -ENOMEM; |
2411 | } | 2413 | } |
2412 | 2414 | ||
2413 | ext4_groupinfo_caches[cache_index] = cachep; | ||
2414 | |||
2415 | return 0; | 2415 | return 0; |
2416 | } | 2416 | } |
2417 | 2417 | ||