Skip to contentSkip to conversation

misc: sram: Replace devm_kasprintf() call by devm_kstrdup() in sram_reserve_regions()

PATCH New Markus Elfring 1 participant 1 message Apr 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: sram: Replace devm_kasprintf() call by devm_kstrdup() in sram_reserve_regions()

From: Markus Elfring <[email protected]>
Date: Wed, 16 Apr 2025 16:10:06 +0200

Use a devm_kstrdup() call instead of a devm_kasprintf() call in this function implementation because only a single string should be copied.

The source code was transformed by using the Coccinelle software.

---
 drivers/misc/sram.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/misc/sram.c +3 -2
index e5069882457e..5a2412ca43cd 100644
@@ -235,8 +235,9 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
 				goto err_chunks;
 			}
 			if (!label)
-				block->label = devm_kasprintf(sram->dev, GFP_KERNEL,
-							      "%s", of_node_full_name(child));
+				block->label = devm_kstrdup(sram->dev,
+							    of_node_full_name(child),
+							    GFP_KERNEL);
 			else
 				block->label = devm_kstrdup(sram->dev,
 							    label, GFP_KERNEL);
Signature · 1 line
2.49.0