WSL2-Linux-Kernel/fs/ubifs
Zhihao Cheng b5fda08ef2 ubifs: Fix memleak when insert_old_idx() failed
Following process will cause a memleak for copied up znode:

dirty_cow_znode
  zn = copy_znode(c, znode);
  err = insert_old_idx(c, zbr->lnum, zbr->offs);
  if (unlikely(err))
     return ERR_PTR(err);   // No one refers to zn.

Fetch a reproducer in [Link].

Function copy_znode() is split into 2 parts: resource allocation
and znode replacement, insert_old_idx() is split in similar way,
so resource cleanup could be done in error handling path without
corrupting metadata(mem & disk).
It's okay that old index inserting is put behind of add_idx_dirt(),
old index is used in layout_leb_in_gaps(), so the two processes do
not depend on each other.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216705
Fixes: 1e51764a3c ("UBIFS: add new flash file system")
Cc: stable@vger.kernel.org
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2023-04-23 23:36:38 +02:00
..
Kconfig
Makefile
auth.c
budget.c ubifs: Reserve one leb for each journal head while doing budget 2023-02-02 21:13:40 +01:00
commit.c
compress.c ubifs: Remove return in compr_exit() 2023-04-21 22:31:03 +02:00
crypto.c ubifs: Fix UBIFS ro fail due to truncate in the encrypted directory 2022-09-21 11:32:38 +02:00
debug.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
debug.h
dir.c ubifs: Fix memory leak in do_rename 2023-04-21 22:38:51 +02:00
file.c This pull request contains updates for JFFS2, UBI and UBIFS 2023-03-01 09:06:51 -08:00
find.c
gc.c
io.c ubifs: Fix kernel-doc 2023-02-02 21:13:53 +01:00
ioctl.c fs: port ->fileattr_set() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
journal.c ubifs: Fix some kernel-doc comments 2023-02-02 21:13:52 +01:00
key.h
log.c
lprops.c
lpt.c
lpt_commit.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
master.c
misc.c
misc.h
orphan.c
recovery.c
replay.c
sb.c
scan.c
shrinker.c
super.c ubifs: Fix memory leak in alloc_wbufs() 2023-02-02 21:13:43 +01:00
sysfs.c ubifs: make kobj_type structures constant 2023-02-13 22:29:54 +01:00
tnc.c ubifs: Fix memleak when insert_old_idx() failed 2023-04-23 23:36:38 +02:00
tnc_commit.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
tnc_misc.c
ubifs-media.h
ubifs.h This pull request contains updates for JFFS2, UBI and UBIFS 2023-03-01 09:06:51 -08:00
xattr.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00