Commit cfa7a9cc authored by Tsutomu Itoh's avatar Tsutomu Itoh Committed by Josef Bacik

Btrfs: fix memory leak in name_cache_insert()

We should free name_cache_entry before returning from the
error handling code.
Signed-off-by: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
parent 57ba86c0
...@@ -1814,8 +1814,10 @@ static int name_cache_insert(struct send_ctx *sctx, ...@@ -1814,8 +1814,10 @@ static int name_cache_insert(struct send_ctx *sctx,
(unsigned long)nce->ino); (unsigned long)nce->ino);
if (!nce_head) { if (!nce_head) {
nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS); nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS);
if (!nce_head) if (!nce_head) {
kfree(nce);
return -ENOMEM; return -ENOMEM;
}
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment