| Submitter | Tao Ma |
|---|---|
| Date | July 11, 2011, 3:26 p.m. |
| Message ID | <1310398016-8104-1-git-send-email-tm@tao.ma> |
| Download | mbox | patch |
| Permalink | /patch/104238/ |
| State | Accepted |
| Headers | show |
Comments
On Mon, Jul 11, 2011 at 11:26:55PM +0800, Tao Ma wrote: > From: Tao Ma <boyu.mt@taobao.com> > > 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> Applied, with a slightly reworded one-line summary: ext4: fix a race which could leak memory in ext4_groupinfo_create_slab() - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 9a35263..c680641 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2404,14 +2404,14 @@ static int ext4_groupinfo_create_slab(size_t size) slab_size, 0, SLAB_RECLAIM_ACCOUNT, NULL); + ext4_groupinfo_caches[cache_index] = cachep; + mutex_unlock(&ext4_grpinfo_slab_create_mutex); if (!cachep) { printk(KERN_EMERG "EXT4: no memory for groupinfo slab cache\n"); return -ENOMEM; } - ext4_groupinfo_caches[cache_index] = cachep; - return 0; }