Messages in this thread Patch in this message | | | From | Luis Chamberlain <> | Subject | [PATCH v2 6/6] block: skip queue if NULL on blk_cleanup_queue() | Date | Wed, 14 Jul 2021 21:55:31 -0700 |
| |
Now that error handling for add_disk*() calls is added, we must accept a common form for when errors are detected on the the add_disk*() calls, and that is to call blk_cleanup_disk() on error always. One of the corner cases possible is a driver bug where the queue is already gone and we cannot blk_get_queue(), and so may be NULL. When blk_cleanup_disk() is called in this case blk_cleanup_queue() will crash with a null dereference.
Make this an accepted condition and just skip it. This allows us to also test for it safely with error injection.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> --- block/blk-core.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/block/blk-core.c b/block/blk-core.c index 04477697ee4b..156f7d3b4bd9 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -372,6 +372,9 @@ void blk_cleanup_queue(struct request_queue *q) /* cannot be called from atomic context */ might_sleep(); + if (!q) + return; + WARN_ON_ONCE(blk_queue_registered(q)); /* mark @q DYING, no new request or merges will be allowed afterwards */ -- 2.27.0
| |