Commit cfa7a9ccda711ac6ab8f0d17c3a9b540092d305a
Committed by
Josef Bacik
1 parent
57ba86c00f
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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 <t-itoh@jp.fujitsu.com>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
fs/btrfs/send.c
... | ... | @@ -1814,8 +1814,10 @@ |
1814 | 1814 | (unsigned long)nce->ino); |
1815 | 1815 | if (!nce_head) { |
1816 | 1816 | nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS); |
1817 | - if (!nce_head) | |
1817 | + if (!nce_head) { | |
1818 | + kfree(nce); | |
1818 | 1819 | return -ENOMEM; |
1820 | + } | |
1819 | 1821 | INIT_LIST_HEAD(nce_head); |
1820 | 1822 | |
1821 | 1823 | ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head); |