scsi: sd: Clean up gendisk if device_add_disk() failed
authorWenchao Hao <haowenchao@huawei.com>
Fri, 1 Apr 2022 01:10:19 +0000 (21:10 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 7 Apr 2022 02:37:49 +0000 (22:37 -0400)
commit03252259e18e63eb56a0d29c2fefcc30b58b812b
treec650f31b845a335e942630b1e121a7971e352837
parent61144d83376a136d8aa7a9e057d916c505bfb75f
scsi: sd: Clean up gendisk if device_add_disk() failed

We forgot to call blk_cleanup_disk() when device_add_disk() failed.  This
would cause a memory leak of gendisk and sched_tags allocated in
elevator_init_mq()

Reference:https://syzkaller.appspot.com/x/log.txt?x=13b41dcb700000
Reported-and-tested-by: syzbot+f08c77040fa163a75a46@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20220401011018.1026553-1-haowenchao@huawei.com
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sd.c