Linux block layer
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@wdc.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Bart Van Assche <bart.vanassche@wdc.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Hannes Reinecke <hare@suse.de>,
	Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH 3/4] skd: Make it easier for static analyzers to analyze skd_free_disk()
Date: Fri, 25 Aug 2017 14:24:13 -0700	[thread overview]
Message-ID: <20170825212414.28322-4-bart.vanassche@wdc.com> (raw)
In-Reply-To: <20170825212414.28322-1-bart.vanassche@wdc.com>

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>
---
 drivers/block/skd_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 8ae0320f02b5..34188a600bfa 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -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)
-- 
2.14.1

  parent reply	other threads:[~2017-08-25 21:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 21:24 [PATCH 0/4] Four more patches for the sTec s1120 driver (skd) Bart Van Assche
2017-08-25 21:24 ` [PATCH 1/4] skd: Rename skd_softirq_done() into skd_complete_rq() Bart Van Assche
2017-08-25 21:24 ` [PATCH 2/4] skd: Inline skd_end_request() Bart Van Assche
2017-08-25 21:24 ` Bart Van Assche [this message]
2017-08-26  6:01   ` [PATCH 3/4] skd: Make it easier for static analyzers to analyze skd_free_disk() Dan Carpenter
2017-08-25 21:24 ` [PATCH 4/4] skd: Remove SKD_ID_INCR Bart Van Assche
2017-08-25 21:30 ` [PATCH 0/4] Four more patches for the sTec s1120 driver (skd) Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170825212414.28322-4-bart.vanassche@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dan.carpenter@oracle.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox