Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: mediatek: mtk-socinfo Add error handling in devm_kasprintf()
@ 2026-07-09 13:24 Griffin Kroah-Hartman
  2026-07-09 13:46 ` AngeloGioacchino Del Regno
  2026-07-09 13:50 ` AngeloGioacchino Del Regno
  0 siblings, 2 replies; 3+ messages in thread
From: Griffin Kroah-Hartman @ 2026-07-09 13:24 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Griffin Kroah-Hartman, Matthias Brugger,
	AngeloGioacchino Del Regno

Add an error check to the devm_kasprintf() function in
mtk_socinfo_create_socinfo_node(), returning -ENOMEM if the function
failed.

Assisted-by: gkh_clanker_t1000
CC: Matthias Brugger <matthias.bgg@gmail.com>
CC: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Griffin Kroah-Hartman <griffin@kroah.com>
---
 drivers/soc/mediatek/mtk-socinfo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-socinfo.c b/drivers/soc/mediatek/mtk-socinfo.c
index 424a1eb82c20..e294730ba709 100644
--- a/drivers/soc/mediatek/mtk-socinfo.c
+++ b/drivers/soc/mediatek/mtk-socinfo.c
@@ -76,11 +76,14 @@ static int mtk_socinfo_create_socinfo_node(struct mtk_socinfo *mtk_socinfop)
 	if (!attrs)
 		return -ENOMEM;
 
-	if (data->marketing_name != NULL && data->marketing_name[0] != '\0')
+	if (data->marketing_name != NULL && data->marketing_name[0] != '\0') {
 		attrs->family = devm_kasprintf(mtk_socinfop->dev, GFP_KERNEL, "MediaTek %s",
 					       data->marketing_name);
-	else
+		if (!attrs->family)
+			return -ENOMEM;
+	} else {
 		attrs->family = soc_manufacturer;
+	}
 
 	attrs->soc_id = data->soc_name;
 	/*
-- 
2.55.0



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

end of thread, other threads:[~2026-07-09 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 13:24 [PATCH] soc: mediatek: mtk-socinfo Add error handling in devm_kasprintf() Griffin Kroah-Hartman
2026-07-09 13:46 ` AngeloGioacchino Del Regno
2026-07-09 13:50 ` AngeloGioacchino Del Regno

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