Skip to contentSkip to conversation

mtip32xx: fix a smatch warning

PATCH In review Asai Thambi S P 2 participants 2 messages Apr 12, 2013 – Apr 14, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtip32xx: fix a smatch warning

Reported smatch warning:
drivers/block/mtip32xx/mtip32xx.c:4163 mtip_block_shutdown() warn: variable dereferenced before check 'dd->disk' (see line 4159)

dd->disk->disk_name accessed before the check if dd->disk is NULL. Fixed this and access of dd->queue/dd->disk->queue.

---
 drivers/block/mtip32xx/mtip32xx.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +8 -10
index 32c6780..d11ea92 100644
@@ -4156,26 +4156,24 @@ static int mtip_block_remove(struct driver_data *dd)
  */
 static int mtip_block_shutdown(struct driver_data *dd)
 {
-	dev_info(&dd->pdev->dev,
-		"Shutting down %s ...\n", dd->disk->disk_name);
-
 	/* Delete our gendisk structure, and cleanup the blk queue. */
 	if (dd->disk) {
-		if (dd->disk->queue)
+		dev_info(&dd->pdev->dev,
+			"Shutting down %s ...\n", dd->disk->disk_name);
+
+		if (dd->disk->queue) {
 			del_gendisk(dd->disk);
-		else
+			blk_cleanup_queue(dd->queue);
+		} else
 			put_disk(dd->disk);
+		dd->disk  = NULL;
+		dd->queue = NULL;
 	}
 
-
 	spin_lock(&rssd_index_lock);
 	ida_remove(&rssd_index_ida, dd->index);
 	spin_unlock(&rssd_index_lock);
 
-	blk_cleanup_queue(dd->queue);
-	dd->disk  = NULL;
-	dd->queue = NULL;
-
 	mtip_hw_shutdown(dd);
 	return 0;
 }
Signature · 1 line
1.7.1
maintainer
#1 lore raw
Quoted 6 lines · Asai Thambi S P

Reported smatch warning:
drivers/block/mtip32xx/mtip32xx.c:4163 mtip_block_shutdown() warn: variable dereferenced before check 'dd->disk' (see line 4159)

dd->disk->disk_name accessed before the check if dd->disk is NULL. Fixed this and access of dd->queue/dd->disk->queue.

Applied for 3.10, thanks.

Signature · 1 line
Jens Axboe