Skip to contentSkip to conversation

backlight: pm8941: Add NULL check in exynos_generic_icc_probe()

PATCH In review Henry Martin 2 participants 3 messages Apr 1, 2025 – Apr 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 backlight: pm8941: Add NULL check in exynos_generic_icc_probe()

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")

---
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(+)
drivers/interconnect/samsung/exynos.c +4 -0
index 9e041365d909..57e779b3e942 100644
@@ -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;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · 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")

---

Best regards,
Krzysztof

#2 lore raw

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?

Quoted 16 lines · Krzysztof Kozlowski <[email protected]> 于2025年4月1日周二 19:00写道:
Quoted 9 lines · 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")

---

Best regards,
Krzysztof