[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221021022102.2231464-7-yangyingliang@huawei.com>
Date: Fri, 21 Oct 2022 10:20:57 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <linux-kernel@...r.kernel.org>, <qemu-devel@...gnu.org>,
<linux-f2fs-devel@...ts.sourceforge.net>,
<linux-erofs@...ts.ozlabs.org>, <ocfs2-devel@....oracle.com>,
<linux-mtd@...ts.infradead.org>, <amd-gfx@...ts.freedesktop.org>
CC: <gregkh@...uxfoundation.org>, <rafael@...nel.org>, <somlo@....edu>,
<mst@...hat.com>, <jaegeuk@...nel.org>, <chao@...nel.org>,
<hsiangkao@...ux.alibaba.com>, <huangjianan@...o.com>,
<mark@...heh.com>, <jlbec@...lplan.org>,
<joseph.qi@...ux.alibaba.com>, <akpm@...ux-foundation.org>,
<alexander.deucher@....com>, <luben.tuikov@....com>,
<richard@....at>, <liushixin2@...wei.com>
Subject: [PATCH 06/11] firmware: qemu_fw_cfg: fix possible memory leak in fw_cfg_build_symlink()
Inject fault while loading module, kset_register() may fail, if
it fails, but the refcount of kobject is not decreased to 0, the
name allocated in kobject_set_name() is leaked. To fix this by
calling kset_put(), so that name can be freed in callback function
kobject_cleanup() and 'subdir' is freed in kset_release().
unreferenced object 0xffff88810ad69050 (size 8):
comm "swapper/0", pid 1, jiffies 4294677178 (age 38.812s)
hex dump (first 8 bytes):
65 74 63 00 81 88 ff ff etc.....
backtrace:
[<00000000a80c7bf1>] __kmalloc_node_track_caller+0x44/0x1b0
[<000000003f0167c7>] kstrdup+0x3a/0x70
[<0000000049336709>] kstrdup_const+0x41/0x60
[<00000000175616e4>] kvasprintf_const+0xf5/0x180
[<000000004bcc30f7>] kobject_set_name_vargs+0x56/0x150
[<000000004b0251bd>] kobject_set_name+0xab/0xe0
[<00000000700151fb>] fw_cfg_sysfs_probe+0xa5b/0x1320
Fixes: 246c46ebaeae ("firmware: create directory hierarchy for sysfs fw_cfg entries")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/firmware/qemu_fw_cfg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index a69399a6b7c0..d036e69cabbb 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -544,7 +544,7 @@ static int fw_cfg_build_symlink(struct kset *dir,
}
ret = kset_register(subdir);
if (ret) {
- kfree(subdir);
+ kset_put(subdir);
break;
}
--
2.25.1
Powered by blists - more mailing lists