summaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-11-06 17:53:53 +0000
committerJens Axboe <axboe@kernel.dk>2017-11-10 19:55:57 -0700
commitf0fba398fec65ff5a2e1bf8ae62718ec0450abaf (patch)
tree6bfdf6ba484c60c1223ee24ef04f426480cc71c9 /block/genhd.c
parent67f2519fe2903c4041c0e94394d14d372fe51399 (diff)
downloadlinux-stable-f0fba398fec65ff5a2e1bf8ae62718ec0450abaf.tar.gz
linux-stable-f0fba398fec65ff5a2e1bf8ae62718ec0450abaf.tar.bz2
linux-stable-f0fba398fec65ff5a2e1bf8ae62718ec0450abaf.zip
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>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 3de1671631bf..997e598f3b86 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -798,7 +798,7 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
spin_unlock_bh(&ext_devt_lock);
}
- if (unlikely(disk->flags & GENHD_FL_HIDDEN)) {
+ if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) {
put_disk(disk);
disk = NULL;
}