public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] edac: versalnet: Use kasprintf() to simplify string allocation.
@ 2025-11-15 19:56 Ayaan Mirza Baig
  2025-11-16 12:02 ` Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Ayaan Mirza Baig @ 2025-11-15 19:56 UTC (permalink / raw)
  To: linux-edac; +Cc: shubhrajyoti.datta, Ayaan Mirza Baig

Replace the kmalloc() + sprintf() pattern with a single call
to kasprintf(). This is cleaner, simpler, and avoids potential
buffer overflows from the fixed-size 32-byte allocation.

Signed-off-by: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
---
 drivers/edac/versalnet_edac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index 1ded4c3f0213..c79509b0a464 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -812,8 +812,7 @@ static int init_versalnet(struct mc_priv *priv, struct platform_device *pdev)
 
 		dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 		dev->release = versal_edac_release;
-		name = kmalloc(32, GFP_KERNEL);
-		sprintf(name, "versal-net-ddrmc5-edac-%d", i);
+		name = kasprintf(GFP_KERNEL, "versal-net-ddrmc5-edac-%d", i);
 		dev->init_name = name;
 		rc = device_register(dev);
 		if (rc)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-11-18 21:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-15 19:56 [PATCH] edac: versalnet: Use kasprintf() to simplify string allocation Ayaan Mirza Baig
2025-11-16 12:02 ` Borislav Petkov
2025-11-16 19:58   ` [PATCH v2] " Ayaan Mirza Baig
2025-11-17  3:26     ` Zhuo, Qiuxu
2025-11-17 11:02       ` [PATCH v3] edac: versalnet: Use kasprintf() to simplify string allocation and fix error paths Ayaan Mirza Baig
2025-11-18 14:02         ` Zhuo, Qiuxu
2025-11-18 18:46           ` Ayaan Mirza Baig
2025-11-18 21:08             ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox