Chen Zhongjin
4e68c5da60
block: Fix possible memory leak for rq_wb on add_disk failure
...
[ Upstream commit fa81cbafbf5764ad5053512152345fab37a1fe18 ]
kmemleak reported memory leaks in device_add_disk():
kmemleak: 3 new suspected memory leaks
unreferenced object 0xffff88800f420800 (size 512):
comm "modprobe", pid 4275, jiffies 4295639067 (age 223.512s)
hex dump (first 32 bytes):
04 00 00 00 08 00 00 00 01 00 00 00 00 00 00 00 ................
00 e1 f5 05 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000d3662699>] kmalloc_trace+0x26/0x60
[<00000000edc7aadc>] wbt_init+0x50/0x6f0
[<0000000069601d16>] wbt_enable_default+0x157/0x1c0
[<0000000028fc393f>] blk_register_queue+0x2a4/0x420
[<000000007345a042>] device_add_disk+0x6fd/0xe40
[<0000000060e6aab0>] nbd_dev_add+0x828/0xbf0 [nbd]
...
It is because the memory allocated in wbt_enable_default() is not
released in device_add_disk() error path.
Normally, these memory are freed in:
del_gendisk()
rq_qos_exit()
rqos->ops->exit(rqos);
wbt_exit()
So rq_qos_exit() is called to free the rq_wb memory for wbt_init().
However in the error path of device_add_disk(), only
blk_unregister_queue() is called and make rq_wb memory leaked.
Add rq_qos_exit() to the error path to fix it.
Fixes: 83cbce957446 ("block: add error handling for device_add_disk / add_disk")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20221029071355.35462-1-chenzhongjin@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-10 18:15:36 +01:00
..
2022-03-16 14:23:46 +01:00
2020-08-23 17:36:59 -05:00
2022-04-27 14:38:50 +02:00
2022-06-09 10:23:19 +02:00
2022-06-09 10:23:19 +02:00
2022-06-09 10:23:19 +02:00
2022-04-08 14:23:55 +02:00
2022-02-08 18:34:05 +01:00
2022-08-17 14:24:01 +02:00
2021-03-05 11:32:15 -07:00
2019-11-07 12:28:13 -07:00
2022-06-09 10:23:32 +02:00
2022-09-23 14:15:48 +02:00
2021-03-11 07:47:48 -07:00
2020-10-05 10:47:43 -06:00
2021-08-25 06:45:00 -06:00
2021-06-30 15:35:45 -06:00
2022-01-27 11:05:25 +01:00
2021-09-14 20:03:30 -06:00
2022-08-11 13:07:50 +02:00
2022-08-17 14:24:24 +02:00
2022-08-17 14:24:24 +02:00
2021-06-21 15:03:40 -06:00
2021-06-21 15:03:40 -06:00
2021-06-17 15:51:20 +02:00
2022-03-08 19:12:31 +01:00
2022-04-08 14:22:59 +02:00
2020-10-20 07:08:17 -06:00
2022-08-17 14:23:12 +02:00
2019-06-13 03:00:30 -06:00
2019-05-31 15:12:34 -06:00
2019-05-31 15:12:34 -06:00
2022-04-08 14:22:59 +02:00
2021-06-24 18:43:55 -06:00
2021-08-02 13:37:29 -06:00
2021-09-12 19:32:43 -06:00
2021-05-24 06:47:22 -06:00
2020-03-17 20:55:21 +01:00
2022-08-31 17:16:50 +02:00
2021-12-01 09:04:56 +01:00
2022-01-27 11:04:15 +01:00
2021-02-22 06:33:48 -07:00
2021-06-08 15:12:57 -06:00
2022-08-17 14:24:24 +02:00
2021-10-27 06:58:01 -06:00
2020-09-01 16:48:46 -06:00
2022-04-08 14:23:07 +02:00
2022-10-26 12:35:47 +02:00
2020-07-31 16:29:47 -06:00
2022-10-26 12:35:54 +02:00
2021-06-21 15:03:41 -06:00
2021-11-18 19:17:15 +01:00
2021-11-18 19:16:16 +01:00
2021-08-02 13:37:28 -06:00
2021-08-01 13:21:40 -04:00
2021-09-14 00:22:15 -04:00
2021-08-23 12:55:45 -06:00
2022-02-23 12:03:15 +01:00
2021-09-24 11:06:58 -06:00
2022-11-10 18:15:36 +01:00
2022-03-16 14:23:46 +01:00
2022-04-27 14:39:02 +02:00
2022-08-11 13:07:50 +02:00
2021-09-02 15:09:46 -07:00
2021-08-11 13:47:26 -06:00
2021-02-22 10:22:54 -08:00
2021-10-15 21:02:57 -06:00
2021-09-11 10:19:51 -07:00
2022-01-27 11:05:25 +01:00
2020-03-12 08:00:10 -06:00
2020-03-12 08:00:10 -06:00
2021-08-02 13:37:28 -06:00