drivers/interconnect/samsung/exynos.c | 4 ++++ 1 file changed, 4 insertions(+)
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
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
© 2016 - 2025 Red Hat, Inc.