Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit 5676e7b

Browse files
Robert Elliottaxboe
authored andcommitted
blk-mq: cleanup after blk_mq_init_rq_map failures
In blk-mq.c blk_mq_alloc_tag_set, if: set->tags = kmalloc_node() succeeds, but one of the blk_mq_init_rq_map() calls fails, goto out_unwind; needs to free set->tags so the caller is not obligated to do so. None of the current callers (null_blk, virtio_blk, virtio_blk, or the forthcoming scsi-mq) do so. set->tags needs to be set to NULL after doing so, so other tag cleanup logic doesn't try to free a stale pointer later. Also set it to NULL in blk_mq_free_tag_set. Tested with error injection on the forthcoming scsi-mq + hpsa combination. Signed-off-by: Robert Elliott <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent dc501dc commit 5676e7b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/blk-mq.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,8 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
19821982
out_unwind:
19831983
while (--i >= 0)
19841984
blk_mq_free_rq_map(set, set->tags[i], i);
1985+
kfree(set->tags);
1986+
set->tags = NULL;
19851987
out:
19861988
return -ENOMEM;
19871989
}
@@ -1997,6 +1999,7 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
19971999
}
19982000

19992001
kfree(set->tags);
2002+
set->tags = NULL;
20002003
}
20012004
EXPORT_SYMBOL(blk_mq_free_tag_set);
20022005

0 commit comments

Comments
 (0)