diff mbox series

block/blk_mq: Only call kfree when set->tags isn't null

Message ID 20231229021220.7337-1-liuwei09@cestc.cn (mailing list archive)
State New, archived
Headers show
Series block/blk_mq: Only call kfree when set->tags isn't null | expand

Commit Message

Liu Wei Dec. 29, 2023, 2:12 a.m. UTC
In function blk_mq_realloc_tag_set_tags, there is a check on set->tags,
but kfree should only be called when set->tags isn't null

Signed-off-by: Liu Wei <liuwei09@cestc.cn>
---
 block/blk-mq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ac18f802c027..07a3fc01d54b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4409,10 +4409,11 @@  static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
 	if (!new_tags)
 		return -ENOMEM;
 
-	if (set->tags)
+	if (set->tags) {
 		memcpy(new_tags, set->tags, set->nr_hw_queues *
 		       sizeof(*set->tags));
-	kfree(set->tags);
+		kfree(set->tags);
+	}
 	set->tags = new_tags;
 
 	for (i = set->nr_hw_queues; i < new_nr_hw_queues; i++) {