From: Tsutomu Itoh Date: Mon, 17 Dec 2012 06:38:51 +0000 (+0000) Subject: Btrfs: fix memory leak in name_cache_insert() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cfa7a9ccda711ac6ab8f0d17c3a9b540092d305a;p=linux-beck.git Btrfs: fix memory leak in name_cache_insert() We should free name_cache_entry before returning from the error handling code. Signed-off-by: Tsutomu Itoh --- diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 54454542ad40..321b7fb4e441 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1814,8 +1814,10 @@ static int name_cache_insert(struct send_ctx *sctx, (unsigned long)nce->ino); if (!nce_head) { nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS); - if (!nce_head) + if (!nce_head) { + kfree(nce); return -ENOMEM; + } INIT_LIST_HEAD(nce_head); ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head);