skd: Make it easier for static analyzers to analyze skd_free_disk()
authorBart Van Assche <bart.vanassche@wdc.com>
Fri, 25 Aug 2017 21:24:13 +0000 (14:24 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Aug 2017 21:29:43 +0000 (15:29 -0600)
Although it is easy to see that skdev->disk != NULL if skdev->queue
!= NULL, add a test for skdev->disk to avoid that smatch reports the
following warning:

drivers/block/skd_main.c:3080 skd_free_disk()
         error: we previously assumed 'disk' could be null (see line 3074)

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/skd_main.c

index 8ae0320f02b5a8593c36879ec8d9eef2e666c7e6..34188a600bfa38b00cfc36c1090915f20942ba4b 100644 (file)
@@ -3041,7 +3041,8 @@ static void skd_free_disk(struct skd_device *skdev)
        if (skdev->queue) {
                blk_cleanup_queue(skdev->queue);
                skdev->queue = NULL;
-               disk->queue = NULL;
+               if (disk)
+                       disk->queue = NULL;
        }
 
        if (skdev->tag_set.tags)