Message ID | 20220401011018.1026553-1-haowenchao@huawei.com |
---|---|
State | New |
Headers | show |
Series | scsi: sd: cleanup gendisk if device_add_disk() failed | expand |
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; }
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(+)