[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220401011018.1026553-1-haowenchao@huawei.com>
Date: Thu, 31 Mar 2022 21:10:19 -0400
From: Wenchao Hao <haowenchao@...wei.com>
To: "James E . J . Bottomley" <jejb@...ux.ibm.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
<linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: <linfeilong@...wei.com>, Wenchao Hao <haowenchao@...wei.com>,
<syzbot+f08c77040fa163a75a46@...kaller.appspotmail.com>
Subject: [PATCH] scsi: sd: cleanup gendisk if device_add_disk() failed
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@...kaller.appspotmail.com
Signed-off-by: Wenchao Hao <haowenchao@...wei.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
Powered by blists - more mailing lists