Эх сурвалжийг харах

clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()

platform_get_resource() may return NULL, add proper
check to avoid potential NULL dereferencing.

This is detected by Coccinelle semantic patch.

@@
expression pdev, res, n, t, e, e1, e2;
@@

res = platform_get_resource(pdev, t, n);
+ if (!res)
+   return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
weiyongjun (A) 7 жил өмнө
parent
commit
9d548d8038

+ 2 - 0
drivers/clk/meson/axg.c

@@ -879,6 +879,8 @@ static int axg_clkc_probe(struct platform_device *pdev)
 
 
 	/*  Generic clocks and PLLs */
 	/*  Generic clocks and PLLs */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 	clk_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 	clk_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 	if (!clk_base) {
 	if (!clk_base) {
 		dev_err(&pdev->dev, "Unable to map clk base\n");
 		dev_err(&pdev->dev, "Unable to map clk base\n");