diff mbox series

[v2] backlight: pm8941: Add NULL check in exynos_generic_icc_probe()

Message ID 20250401104518.25391-1-bsdhenrymartin@gmail.com
State Superseded
Headers show
Series [v2] backlight: pm8941: Add NULL check in exynos_generic_icc_probe() | expand

Commit Message

henry martin April 1, 2025, 10:45 a.m. UTC
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(+)

Comments

henry martin April 24, 2025, 3:03 a.m. UTC | #1
Hi Krzysztof,

Just a friendly reminder about the patch below which received your Reviewed-by
tag but hasn't been applied yet. Could you let me know if there are any further
actions needed?

Krzysztof Kozlowski <krzk@kernel.org> 于2025年4月1日周二 19:00写道:
>
> On 01/04/2025 12:45, Henry Martin wrote:
> > 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>
> > ---
>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>
> Best regards,
> Krzysztof
diff mbox series

Patch

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;