diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-11-06 12:53:53 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-11-10 21:55:57 -0500 |
commit | f0fba398fec65ff5a2e1bf8ae62718ec0450abaf (patch) | |
tree | 6bfdf6ba484c60c1223ee24ef04f426480cc71c9 | |
parent | 67f2519fe2903c4041c0e94394d14d372fe51399 (diff) |
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>
-rw-r--r-- | block/genhd.c | 2 |
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) | |||
798 | spin_unlock_bh(&ext_devt_lock); | 798 | spin_unlock_bh(&ext_devt_lock); |
799 | } | 799 | } |
800 | 800 | ||
801 | if (unlikely(disk->flags & GENHD_FL_HIDDEN)) { | 801 | if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) { |
802 | put_disk(disk); | 802 | put_disk(disk); |
803 | disk = NULL; | 803 | disk = NULL; |
804 | } | 804 | } |