linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] fix memory leak while kset_register() fails
@ 2022-10-21  2:20 Yang Yingliang
  2022-10-21  2:20 ` [PATCH 01/11] kset: fix documentation for kset_register() Yang Yingliang
                   ` (11 more replies)
  0 siblings, 12 replies; 33+ messages in thread
From: Yang Yingliang @ 2022-10-21  2:20 UTC (permalink / raw)
  To: linux-kernel, qemu-devel, linux-f2fs-devel, linux-erofs,
	ocfs2-devel, linux-mtd, amd-gfx
  Cc: gregkh, rafael, somlo, mst, jaegeuk, chao, hsiangkao,
	huangjianan, mark, jlbec, joseph.qi, akpm, alexander.deucher,
	luben.tuikov, richard, liushixin2

The previous discussion link:
https://lore.kernel.org/lkml/0db486eb-6927-927e-3629-958f8f211194@huawei.com/T/

kset_register() is currently used in some places without calling
kset_put() in error path, because the callers think it should be
kset internal thing to do, but the driver core can not know what
caller doing with that memory at times. The memory could be freed
both in kset_put() and error path of caller, if it is called in
kset_register().

So make the function documentation more explicit about calling
kset_put() in the error path of caller first, so that people
have a chance to know what to do here, then fixes this leaks
by calling kset_put() from callers.

Liu Shixin (1):
  ubifs: Fix memory leak in ubifs_sysfs_init()

Yang Yingliang (10):
  kset: fix documentation for kset_register()
  kset: add null pointer check in kset_put()
  bus: fix possible memory leak in bus_register()
  kobject: fix possible memory leak in kset_create_and_add()
  class: fix possible memory leak in __class_register()
  firmware: qemu_fw_cfg: fix possible memory leak in
    fw_cfg_build_symlink()
  f2fs: fix possible memory leak in f2fs_init_sysfs()
  erofs: fix possible memory leak in erofs_init_sysfs()
  ocfs2: possible memory leak in mlog_sys_init()
  drm/amdgpu/discovery: fix possible memory leak

 drivers/base/bus.c                            | 4 +++-
 drivers/base/class.c                          | 6 ++++++
 drivers/firmware/qemu_fw_cfg.c                | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 5 +++--
 fs/erofs/sysfs.c                              | 4 +++-
 fs/f2fs/sysfs.c                               | 4 +++-
 fs/ocfs2/cluster/masklog.c                    | 7 ++++++-
 fs/ubifs/sysfs.c                              | 2 ++
 include/linux/kobject.h                       | 3 ++-
 lib/kobject.c                                 | 5 ++++-
 10 files changed, 33 insertions(+), 9 deletions(-)

-- 
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2022-10-21 23:49 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21  2:20 [PATCH 00/11] fix memory leak while kset_register() fails Yang Yingliang
2022-10-21  2:20 ` [PATCH 01/11] kset: fix documentation for kset_register() Yang Yingliang
2022-10-21  5:34   ` Luben Tuikov
2022-10-21  8:05     ` Yang Yingliang
2022-10-21  8:16       ` Greg KH
2022-10-21  8:18       ` Luben Tuikov
2022-10-21  2:20 ` [PATCH 02/11] kset: add null pointer check in kset_put() Yang Yingliang
2022-10-21  2:20 ` [PATCH 03/11] bus: fix possible memory leak in bus_register() Yang Yingliang
2022-10-21  2:20 ` [PATCH 04/11] kobject: fix possible memory leak in kset_create_and_add() Yang Yingliang
2022-10-21  2:20 ` [PATCH 05/11] class: fix possible memory leak in __class_register() Yang Yingliang
2022-10-21  2:20 ` [PATCH 06/11] firmware: qemu_fw_cfg: fix possible memory leak in fw_cfg_build_symlink() Yang Yingliang
2022-10-21  2:20 ` [PATCH 07/11] f2fs: fix possible memory leak in f2fs_init_sysfs() Yang Yingliang
2022-10-21  2:20 ` [PATCH 08/11] erofs: fix possible memory leak in erofs_init_sysfs() Yang Yingliang
2022-10-21  2:21 ` [PATCH 09/11] ocfs2: possible memory leak in mlog_sys_init() Yang Yingliang
2022-10-21  2:21 ` [PATCH 10/11] drm/amdgpu/discovery: fix possible memory leak Yang Yingliang
2022-10-21  2:21 ` [PATCH 11/11] ubifs: Fix memory leak in ubifs_sysfs_init() Yang Yingliang
2022-10-21  5:29 ` [PATCH 00/11] fix memory leak while kset_register() fails Luben Tuikov
2022-10-21  5:37   ` Greg KH
2022-10-21  7:55     ` Luben Tuikov
2022-10-21  8:18       ` Greg KH
2022-10-21  8:24         ` Luben Tuikov
2022-10-21  8:41           ` Luben Tuikov
2022-10-21  9:23             ` Yang Yingliang
2022-10-21  8:24     ` Yang Yingliang
2022-10-21  8:36       ` Greg KH
2022-10-21  8:52         ` Luben Tuikov
2022-10-21  8:59         ` Yang Yingliang
2022-10-21  9:08           ` Luben Tuikov
2022-10-21  9:56             ` Yang Yingliang
2022-10-21 23:45               ` Luben Tuikov
2022-10-21  9:12         ` Yang Yingliang
2022-10-21 23:48           ` Luben Tuikov
2022-10-21  7:25   ` Yang Yingliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).