mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 15:10:38 +00:00
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>
This commit is contained in:
parent
67f2519fe2
commit
f0fba398fe
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user