Skip to content

Commit 4e6db0f

Browse files
Dan Carpenteraxboe
authored andcommitted
blk-mq: Add a NULL check in blk_mq_free_map_and_requests()
I recently found some code which called blk_mq_free_map_and_requests() with a NULL set->tags pointer. I fixed the caller, but it seems like a good idea to add a NULL check here as well. Now we can call: blk_mq_free_tag_set(set); blk_mq_free_tag_set(set); twice in a row and it's harmless. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 49379e6 commit 4e6db0f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-mq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,7 @@ static bool __blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, int hctx_idx)
23412341
static void blk_mq_free_map_and_requests(struct blk_mq_tag_set *set,
23422342
unsigned int hctx_idx)
23432343
{
2344-
if (set->tags[hctx_idx]) {
2344+
if (set->tags && set->tags[hctx_idx]) {
23452345
blk_mq_free_rqs(set, set->tags[hctx_idx], hctx_idx);
23462346
blk_mq_free_rq_map(set->tags[hctx_idx]);
23472347
set->tags[hctx_idx] = NULL;

0 commit comments

Comments
 (0)