nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group
authorNanyong Sun <sunnanyong@huawei.com>
Wed, 8 Sep 2021 03:00:15 +0000 (20:00 -0700)
committerDom Cobley <popcornmix@gmail.com>
Thu, 14 Oct 2021 11:33:04 +0000 (12:33 +0100)
commit606237912bcd8b588b70d460d848ff39f9c0921f
tree50b24379649be95d03101f5a77bb5b2fc92257cb
parent675b4d3137512ad9738f00fb1f3faa270974896f
nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group

[ Upstream commit 24f8cb1ed057c840728167dab33b32e44147c86f ]

If kobject_init_and_add return with error, kobject_put() is needed here to
avoid memory leak, because kobject_init_and_add may return error without
freeing the memory associated with the kobject it allocated.

Link: https://lkml.kernel.org/r/20210629022556.3985106-4-sunnanyong@huawei.com
Link: https://lkml.kernel.org/r/1625651306-10829-4-git-send-email-konishi.ryusuke@gmail.com
Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nilfs2/sysfs.c