Skip to contentSkip to conversation

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

PATCH New Liu Wei 1 participant 1 message Dec 29, 2023 Block layer

lore
Share & tools
lore

Liu Wei

author
#0 lore raw

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

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

---
 block/blk-mq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/blk-mq.c +3 -2
index ac18f802c027..07a3fc01d54b 100644
@@ -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++) {
Signature · 1 line
2.42.1