[PATCH 1/9] ublk: don't try to stop disk if ->ub_disk is NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In ublk_stop_dev(), if ublk device state becomes UBLK_S_DEV_DEAD, we
will return immediately. This way is correct, but not enough, because
ublk device may transition to other state, such UBLK_S_DEV_QUIECED,
when it may have been stopped already. Then kernel panic is triggered.

Fix it by checking ->ub_disk directly, this way is simpler and effective
since ub->mutex covers ->ub_disk change.

Fixes: bbae8d1f526b ("ublk_drv: consider recovery feature in aborting mechanism")
Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index cdb1543fa4a9..15de4881f25b 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1784,7 +1784,7 @@ static void ublk_stop_dev(struct ublk_device *ub)
 	struct gendisk *disk;
 
 	mutex_lock(&ub->mutex);
-	if (ub->dev_info.state == UBLK_S_DEV_DEAD)
+	if (!ub->ub_disk)
 		goto unlock;
 	if (ublk_nosrv_dev_should_queue_io(ub)) {
 		if (ub->dev_info.state == UBLK_S_DEV_LIVE)
-- 
2.47.0





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux