]> git.ipfire.org Git - thirdparty/linux.git/commit
f2fs: fix uninitialized kobject put in f2fs_init_sysfs()
authorGuangshuo Li <lgs201920130244@gmail.com>
Fri, 10 Apr 2026 12:47:26 +0000 (20:47 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 13 Apr 2026 22:53:17 +0000 (22:53 +0000)
commitb635f2ecdb5ad34f9c967cabb704d6bed9382fd0
treeda849c7ed49fc5fe00820127439e5fb819cecfb6
parent5909bedbed38c558bee7cb6758ceedf9bc3a9194
f2fs: fix uninitialized kobject put in f2fs_init_sysfs()

In f2fs_init_sysfs(), all failure paths after kset_register() jump to
put_kobject, which unconditionally releases both f2fs_tune and
f2fs_feat.

If kobject_init_and_add(&f2fs_feat, ...) fails, f2fs_tune has not been
initialized yet, so calling kobject_put(&f2fs_tune) is invalid.

Fix this by splitting the unwind path so each error path only releases
objects that were successfully initialized.

Fixes: a907f3a68ee26ba4 ("f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/sysfs.c