mirror of https://gitee.com/openkylin/linux.git
Btrfs: free nce and nce_head on error in name_cache_insert
Both were leaked in case of error. Reported-by: Alex Lyakas <alex.bolshoy.btrfs@gmail.com> Signed-off-by: Alexander Block <ablock84@googlemail.com>
This commit is contained in:
parent
3e126f32f8
commit
5dc67d0ba9
|
@ -1759,6 +1759,7 @@ static int did_overwrite_first_ref(struct send_ctx *sctx, u64 ino, u64 gen)
|
||||||
* Insert a name cache entry. On 32bit kernels the radix tree index is 32bit,
|
* 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
|
* 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.
|
* 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,
|
static int name_cache_insert(struct send_ctx *sctx,
|
||||||
struct name_cache_entry *nce)
|
struct name_cache_entry *nce)
|
||||||
|
@ -1775,9 +1776,12 @@ static int name_cache_insert(struct send_ctx *sctx,
|
||||||
INIT_LIST_HEAD(nce_head);
|
INIT_LIST_HEAD(nce_head);
|
||||||
|
|
||||||
ret = radix_tree_insert(&sctx->name_cache, nce->ino, 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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
list_add_tail(&nce->radix_list, nce_head);
|
list_add_tail(&nce->radix_list, nce_head);
|
||||||
list_add_tail(&nce->list, &sctx->name_cache_list);
|
list_add_tail(&nce->list, &sctx->name_cache_list);
|
||||||
sctx->name_cache_size++;
|
sctx->name_cache_size++;
|
||||||
|
|
Loading…
Reference in New Issue