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

* Re: [PATCH] soc: mediatek: mtk-socinfo Add error handling in devm_kasprintf()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-09 13:46 UTC (permalink / raw)
  To: Griffin Kroah-Hartman, linux-kernel, linux-arm-kernel,
	linux-mediatek
  Cc: Matthias Brugger

On 7/9/26 15:24, Griffin Kroah-Hartman wrote:
> 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>

Yeah, makes sense.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.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;
>   	/*


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

* Re: [PATCH] soc: mediatek: mtk-socinfo Add error handling in devm_kasprintf()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-09 13:50 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-mediatek,
	Griffin Kroah-Hartman
  Cc: Matthias Brugger

On Thu, 09 Jul 2026 15:24:16 +0200, Griffin Kroah-Hartman wrote:
> Add an error check to the devm_kasprintf() function in
> mtk_socinfo_create_socinfo_node(), returning -ENOMEM if the function
> failed.

Applied to v7.2-next/soc, thanks!

[1/1] soc: mediatek: mtk-socinfo Add error handling in devm_kasprintf()
      commit: e4a3c99bbf779d6357adb8101ad18f34c2194306

Cheers,
Angelo




^ permalink raw reply	[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