From: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>Reviewed-by: Hannes Reinecke <hare@xxxxxxx>
When nr_hw_queues shrink, we free the excess tags before realloc
hw_ctxs for each queue, during that we may need to access those
tags, like blk_mq_tag_idle(hctx) will access queue shared tags.
So slab-use-after-free caused and reported by KASAN. Fix it by
moving the releasing of excess tags to the end.
Fixes: e1dd7bc93029 ("blk-mq: fix tags leak when shrink nr_hw_queues")
Reported-by: Yi Zhang <yi.zhang@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/CAHj4cs_CK63uoDpGBGZ6DN4OCTpzkR3UaVgK=LX8Owr8ej2ieQ@xxxxxxxxxxxxxx/
Cc: Ming Lei <ming.lei@xxxxxxxxxx>
Signed-off-by: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>
---
block/blk-mq.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)