提交 f0fba398 编写于 作者: C Colin Ian King 提交者: Jens Axboe

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: 8ddcd653 ("block: introduce GENHD_FL_HIDDEN")
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 67f2519f
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册