From: Alexander Block Date: Wed, 1 Aug 2012 10:07:43 +0000 (+0200) Subject: Btrfs: free nce and nce_head on error in name_cache_insert X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5dc67d0ba915cda01ed3a980502945edf2c46b70;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git Btrfs: free nce and nce_head on error in name_cache_insert Both were leaked in case of error. Reported-by: Alex Lyakas Signed-off-by: Alexander Block --- diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index b0f9df30f24d..cfbe987f854b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1759,6 +1759,7 @@ out: * Insert a name cache entry. On 32bit kernels the radix tree index is 32bit, * so we need to do some special handling in case we have clashes. This function * takes care of this with the help of name_cache_entry::radix_list. + * In case of error, nce is kfreed. */ static int name_cache_insert(struct send_ctx *sctx, struct name_cache_entry *nce) @@ -1775,8 +1776,11 @@ static int name_cache_insert(struct send_ctx *sctx, INIT_LIST_HEAD(nce_head); ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head); - if (ret < 0) + if (ret < 0) { + kfree(nce_head); + kfree(nce); return ret; + } } list_add_tail(&nce->radix_list, nce_head); list_add_tail(&nce->list, &sctx->name_cache_list);