* [PATCH] block: avoid null pointer dereference on null disk
@ 2017-11-06 17:53 Colin King
2017-11-10 8:20 ` Christoph Hellwig
2017-11-10 15:26 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-11-06 17:53 UTC (permalink / raw)
To: Jens Axboe, linux-block; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
block/genhd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/genhd.c b/block/genhd.c
index d85dcc701d76..42908a7186cd 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;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: avoid null pointer dereference on null disk
2017-11-06 17:53 [PATCH] block: avoid null pointer dereference on null disk Colin King
@ 2017-11-10 8:20 ` Christoph Hellwig
2017-11-10 15:26 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2017-11-10 8:20 UTC (permalink / raw)
To: Colin King; +Cc: Jens Axboe, linux-block, kernel-janitors, linux-kernel
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: avoid null pointer dereference on null disk
2017-11-06 17:53 [PATCH] block: avoid null pointer dereference on null disk Colin King
2017-11-10 8:20 ` Christoph Hellwig
@ 2017-11-10 15:26 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2017-11-10 15:26 UTC (permalink / raw)
To: Colin King, linux-block; +Cc: kernel-janitors, linux-kernel
On 11/06/2017 10:53 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-10 15:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 17:53 [PATCH] block: avoid null pointer dereference on null disk Colin King
2017-11-10 8:20 ` Christoph Hellwig
2017-11-10 15:26 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).