* [PATCH] scsi: sd: cleanup gendisk if device_add_disk() failed
@ 2022-04-01 1:10 Wenchao Hao
0 siblings, 0 replies; only message in thread
From: Wenchao Hao @ 2022-04-01 1:10 UTC (permalink / raw)
To: James E . J . Bottomley, Martin K . Petersen, linux-scsi, linux-kernel
Cc: linfeilong, Wenchao Hao, syzbot+f08c77040fa163a75a46
We forget to call blk_cleanup_disk() when device_add_disk() failed.
Which would cause memory leak of gendisk and sched_tags alloced in
elevator_init_mq()
Reference:https://syzkaller.appspot.com/x/log.txt?x=13b41dcb700000
Reported-and-tested-by: syzbot+f08c77040fa163a75a46@syzkaller.appspotmail.com
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
---
drivers/scsi/sd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a390679cf458..4620a1158272 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3475,6 +3475,7 @@ static int sd_probe(struct device *dev)
error = device_add_disk(dev, gd, NULL);
if (error) {
put_device(&sdkp->disk_dev);
+ blk_cleanup_disk(gd);
goto out;
}
--
2.32.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-31 12:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 1:10 [PATCH] scsi: sd: cleanup gendisk if device_add_disk() failed Wenchao Hao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.