
Zhang XiaoxuandGreg Kroah-Hartman
330bc5533e
mtd: Fix device name leak when register device failed in add_mtd_device()
[ Upstream commit 895d68a394 ]
There is a kmemleak when register device failed:
unreferenced object 0xffff888101aab550 (size 8):
comm "insmod", pid 3922, jiffies 4295277753 (age 925.408s)
hex dump (first 8 bytes):
6d 74 64 30 00 88 ff ff mtd0....
backtrace:
[<00000000bde26724>] __kmalloc_node_track_caller+0x4e/0x150
[<000000003c32b416>] kvasprintf+0xb0/0x130
[<000000001f7a8f15>] kobject_set_name_vargs+0x2f/0xb0
[<000000006e781163>] dev_set_name+0xab/0xe0
[<00000000e30d0c78>] add_mtd_device+0x4bb/0x700
[<00000000f3d34de7>] mtd_device_parse_register+0x2ac/0x3f0
[<00000000c0d88488>] 0xffffffffa0238457
[<00000000b40d0922>] 0xffffffffa02a008f
[<0000000023d17b9d>] do_one_initcall+0x87/0x2a0
[<00000000770f6ca6>] do_init_module+0xdf/0x320
[<000000007b6768fe>] load_module+0x2f98/0x3330
[<00000000346bed5a>] __do_sys_finit_module+0x113/0x1b0
[<00000000674c2290>] do_syscall_64+0x35/0x80
[<000000004c6a8d97>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
If register device failed, should call put_device() to give up the
reference.
Fixes: 1f24b5a8ec ("[MTD] driver model updates")
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221022121352.2534682-1-zhangxiaoxu5@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-14 10:15:28 +01:00
..
2022-11-25 17:45:50 +01:00
2023-01-14 10:15:21 +01:00
2023-01-04 11:39:18 +01:00
2023-01-14 10:15:23 +01:00
2023-01-14 10:15:21 +01:00
2022-11-25 17:45:47 +01:00
2022-12-14 11:31:58 +01:00
2022-12-02 17:39:59 +01:00
2023-01-14 10:15:15 +01:00
2023-01-14 10:15:27 +01:00
2023-01-14 10:15:20 +01:00
2023-01-14 10:15:18 +01:00
2023-01-14 10:15:15 +01:00
2022-11-16 09:57:20 +01:00
2022-12-02 17:40:01 +01:00
2023-01-14 10:15:18 +01:00
2022-11-25 17:45:53 +01:00
2022-12-14 11:32:00 +01:00
2023-01-14 10:15:26 +01:00
2022-12-21 17:32:07 +01:00
2022-12-02 17:40:00 +01:00
2022-12-08 11:23:57 +01:00
2022-11-16 09:57:07 +01:00
2022-11-10 18:14:25 +01:00
2022-12-08 11:23:59 +01:00
2022-12-08 11:23:54 +01:00
2022-11-10 18:14:17 +01:00
2022-12-08 11:23:59 +01:00
2022-12-08 11:23:58 +01:00
2023-01-14 10:15:18 +01:00
2022-11-25 17:45:46 +01:00
2022-12-02 17:40:05 +01:00
2023-01-14 10:15:27 +01:00
2022-11-25 17:45:41 +01:00
2022-11-25 17:45:54 +01:00
2022-12-08 11:23:58 +01:00
2023-01-14 10:15:28 +01:00
2023-01-14 10:15:25 +01:00
2022-12-02 17:40:02 +01:00
2022-12-19 12:27:32 +01:00
2022-12-08 11:23:55 +01:00
2022-11-10 18:14:27 +01:00
2022-11-25 17:45:44 +01:00
2023-01-14 10:15:12 +01:00
2022-11-16 09:57:08 +01:00
2022-12-19 12:27:31 +01:00
2023-01-14 10:15:22 +01:00
2023-01-14 10:15:17 +01:00
2023-01-14 10:15:23 +01:00
2022-12-14 11:31:54 +01:00
2022-12-14 11:31:59 +01:00
2022-12-02 17:40:02 +01:00
2022-12-02 17:39:59 +01:00
2022-11-25 17:45:44 +01:00
2022-11-25 17:45:50 +01:00
2023-01-14 10:15:11 +01:00
2022-12-08 11:23:54 +01:00
2022-11-10 18:14:22 +01:00
2022-11-25 17:45:55 +01:00
2022-12-02 17:39:59 +01:00
2022-12-08 11:23:59 +01:00
2023-01-14 10:15:09 +01:00
2022-12-14 11:31:54 +01:00
2023-01-14 10:15:21 +01:00