block: avoid null pointer dereference on null disk
authorColin Ian King <colin.king@canonical.com>
Mon, 6 Nov 2017 17:53:53 +0000 (17:53 +0000)
committerJens Axboe <axboe@kernel.dk>
Sat, 11 Nov 2017 02:55:57 +0000 (19:55 -0700)
commitf0fba398fec65ff5a2e1bf8ae62718ec0450abaf
tree6bfdf6ba484c60c1223ee24ef04f426480cc71c9
parent67f2519fe2903c4041c0e94394d14d372fe51399
block: avoid null pointer dereference on null disk

It is possible that the pointer disk can be null and hence
we can get a null pointer deference when accessing disk->flags.
Add a null pointer check to avoid the dereference.

Detected by CoverityScan, CID#1461133 ("Explicit null dereferenced")

Fixes: 8ddcd653257c ("block: introduce GENHD_FL_HIDDEN")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c