linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
@ 2018-01-05  1:50 Wei Yongjun
  2018-01-05  9:09 ` Jerome Brunet
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wei Yongjun @ 2018-01-05  1:50 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 drivers/clk/meson/axg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index d883bef..1294f3a 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -879,6 +879,8 @@ static int axg_clkc_probe(struct platform_device *pdev)
 
 	/*  Generic clocks and PLLs */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 	clk_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 	if (!clk_base) {
 		dev_err(&pdev->dev, "Unable to map clk base\n");

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

* [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
  2018-01-05  1:50 [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe() Wei Yongjun
@ 2018-01-05  9:09 ` Jerome Brunet
  2018-01-05 16:24   ` Stephen Boyd
  2018-01-10 21:18 ` Stephen Boyd
  2018-01-10 21:24 ` Stephen Boyd
  2 siblings, 1 reply; 5+ messages in thread
From: Jerome Brunet @ 2018-01-05  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2018-01-05 at 01:50 +0000, Wei Yongjun wrote:
> 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>
> ---

Looks good. Thank you.

Stephen, do you prefer to take this directly ?

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

* [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
  2018-01-05  9:09 ` Jerome Brunet
@ 2018-01-05 16:24   ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2018-01-05 16:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/05, Jerome Brunet wrote:
> On Fri, 2018-01-05 at 01:50 +0000, Wei Yongjun wrote:
> > 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>
> > ---
> 
> Looks good. Thank you.
> 
> Stephen, do you prefer to take this directly ?

Yes. Will do today.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
  2018-01-05  1:50 [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe() Wei Yongjun
  2018-01-05  9:09 ` Jerome Brunet
@ 2018-01-10 21:18 ` Stephen Boyd
  2018-01-10 21:24 ` Stephen Boyd
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2018-01-10 21:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/05, Wei Yongjun wrote:
> 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);

Can this script be put into scripts/coccinelle/? I'd like to be
able to run it instead of getting emails from you after patches
merge.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
  2018-01-05  1:50 [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe() Wei Yongjun
  2018-01-05  9:09 ` Jerome Brunet
  2018-01-10 21:18 ` Stephen Boyd
@ 2018-01-10 21:24 ` Stephen Boyd
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2018-01-10 21:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/05, Wei Yongjun wrote:
> 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>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2018-01-10 21:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-05  1:50 [PATCH -next] clk: meson-axg: fix potential NULL dereference in axg_clkc_probe() Wei Yongjun
2018-01-05  9:09 ` Jerome Brunet
2018-01-05 16:24   ` Stephen Boyd
2018-01-10 21:18 ` Stephen Boyd
2018-01-10 21:24 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).