Skip to content

Commit

Permalink
Btrfs: fix memory leak in name_cache_insert()
Browse files Browse the repository at this point in the history
We should free name_cache_entry before returning from the
error handling code.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
  • Loading branch information
Tsutomu Itoh authored and Josef Bacik committed Jan 14, 2013
1 parent 57ba86c commit cfa7a9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cfa7a9c

Please sign in to comment.