Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] backlight: pm8941: Add NULL check in exynos_generic_icc_probe()
@ 2025-04-01 10:45 Henry Martin
  2025-04-01 11:00 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Henry Martin @ 2025-04-01 10:45 UTC (permalink / raw)
  To: georgi.djakov, krzk
  Cc: s.nawrocki, a.swigon, alim.akhtar, linux-pm, linux-samsung-soc,
	linux-arm-kernel, linux-kernel, Henry Martin

devm_kasprintf() returns NULL when memory allocation fails. Currently,
exynos_generic_icc_probe() does not check for this case, which results
in a NULL pointer dereference.

Add NULL check after devm_kasprintf() to prevent this issue.

Fixes: 2f95b9d5cf0b ("interconnect: Add generic interconnect driver for Exynos SoCs")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
V1 -> V2: The fix ensures icc_node cleanup on devm_kasprintf() failure
without restructuring the proven error handling workflow.

 drivers/interconnect/samsung/exynos.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/interconnect/samsung/exynos.c b/drivers/interconnect/samsung/exynos.c
index 9e041365d909..57e779b3e942 100644
--- a/drivers/interconnect/samsung/exynos.c
+++ b/drivers/interconnect/samsung/exynos.c
@@ -134,6 +134,10 @@ static int exynos_generic_icc_probe(struct platform_device *pdev)
 	priv->node = icc_node;
 	icc_node->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn",
 					bus_dev->of_node);
+	if (!icc_node->name) {
+		ret = -ENOMEM;
+		goto err_node_del;
+	}
 	if (of_property_read_u32(bus_dev->of_node, "samsung,data-clock-ratio",
 				 &priv->bus_clk_ratio))
 		priv->bus_clk_ratio = EXYNOS_ICC_DEFAULT_BUS_CLK_RATIO;
-- 
2.34.1



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

end of thread, other threads:[~2025-04-24  3:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 10:45 [PATCH v2] backlight: pm8941: Add NULL check in exynos_generic_icc_probe() Henry Martin
2025-04-01 11:00 ` Krzysztof Kozlowski
2025-04-24  3:03   ` henry martin

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