mtip32xx: fix for crash when the device surprise removed during rebuild
PATCH 3/3 mtip32xx: fix for crash when the device surprise removed during rebuild
When rebuild is in progress, disk->queue is yet to be created. Surprise removing the device will call remove()-> del_gendisk(). del_gendisk() expect disk->queue be not NULL. Fix is to call put_disk() when disk_queue is NULL.
Signed-off-by Asai Thambi S P <[email protected]>
--- drivers/block/mtip32xx/mtip32xx.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +13 -2
@@ -3967,7 +3967,12 @@ static int mtip_block_remove(struct driver_data *dd)* Delete our gendisk structure. This also removes the device * from /dev */ -del_gendisk (dd->disk); +if (dd->disk) { +if (dd->disk->queue) +del_gendisk (dd->disk); +else +put_disk (dd->disk); + }spin_lock (&rssd_index_lock);ida_remove (&rssd_index_ida, dd->index);
@@ -4001,7 +4006,13 @@ static int mtip_block_shutdown(struct driver_data *dd) "Shutting down %s ...\n", dd->disk->disk_name);/* Delete our gendisk structure, and cleanup the blk queue. */ -del_gendisk (dd->disk); +if (dd->disk) { +if (dd->disk->queue) +del_gendisk (dd->disk); +else +put_disk (dd->disk); + } +spin_lock (&rssd_index_lock);ida_remove (&rssd_index_ida, dd->index);
Signature · 1 line
1.7.1