Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a79e1ac authored by Asai Thambi S P's avatar Asai Thambi S P Committed by Jens Axboe
Browse files

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.

Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAsai Thambi S P <asamymuthupa@micron.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent cef52797
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -4053,26 +4053,24 @@ static int mtip_block_remove(struct driver_data *dd)
 */
static int mtip_block_shutdown(struct driver_data *dd)
{
	/* Delete our gendisk structure, and cleanup the blk queue. */
	if (dd->disk) {
		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)
		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;
}