diff mbox series

[-next] clk: npcm7xx: fix return value check in npcm7xx_clk_init()

Message ID 1524741668-158135-1-git-send-email-weiyongjun1@huawei.com
State Not Applicable, archived
Headers show
Series [-next] clk: npcm7xx: fix return value check in npcm7xx_clk_init() | expand

Commit Message

Wei Yongjun April 26, 2018, 11:21 a.m. UTC
In case of error, the function ioremap() returns NULL pointer not
ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: fcfd14369856 ("clk: npcm7xx: add clock controller")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/clk/clk-npcm7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Boyd May 1, 2018, 9:50 p.m. UTC | #1
Quoting Wei Yongjun (2018-04-26 04:21:08)
> In case of error, the function ioremap() returns NULL pointer not
> ERR_PTR(). The IS_ERR() test in the return value check should be
> replaced with NULL test.
> 
> Fixes: fcfd14369856 ("clk: npcm7xx: add clock controller")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Have you made this into a scripts/coccinelle/ script I can run?

Applied to clk-next
Tali Perry May 2, 2018, 9:19 a.m. UTC | #2
I added the fix Wei Yongjun indicated ( Thanks Wei !)
and another fix similar to the above + error print change.

I'm a newbie... what's scripts/coccinelle/ script ?
I just made a new patch same way I did before. Is this OK?

On Wed, May 2, 2018 at 12:50 AM, Stephen Boyd <sboyd@kernel.org> wrote:
> Quoting Wei Yongjun (2018-04-26 04:21:08)
>> In case of error, the function ioremap() returns NULL pointer not
>> ERR_PTR(). The IS_ERR() test in the return value check should be
>> replaced with NULL test.
>>
>> Fixes: fcfd14369856 ("clk: npcm7xx: add clock controller")
>> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
>
> Have you made this into a scripts/coccinelle/ script I can run?
>
> Applied to clk-next
Julia Lawall May 2, 2018, 10:36 a.m. UTC | #3
On Wed, 2 May 2018, Tali Perry wrote:

> I added the fix Wei Yongjun indicated ( Thanks Wei !)
> and another fix similar to the above + error print change.
>
> I'm a newbie... what's scripts/coccinelle/ script ?
> I just made a new patch same way I did before. Is this OK?

With Coccinelle, you can make a rule that can be put into the Linux kernel
that can allow others to find this problem automatically. Maybe:

@@
expression e,e1;
statement S1,S2;
@@

e = ioremap(...);
... when != e = e1
if (
-    IS_ERR(e)
+    !e
   )
  S1 else S2

http://coccinelle.lip6.fr/

julia

>
> On Wed, May 2, 2018 at 12:50 AM, Stephen Boyd <sboyd@kernel.org> wrote:
> > Quoting Wei Yongjun (2018-04-26 04:21:08)
> >> In case of error, the function ioremap() returns NULL pointer not
> >> ERR_PTR(). The IS_ERR() test in the return value check should be
> >> replaced with NULL test.
> >>
> >> Fixes: fcfd14369856 ("clk: npcm7xx: add clock controller")
> >> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> >
> > Have you made this into a scripts/coccinelle/ script I can run?
> >
> > Applied to clk-next
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
diff mbox series

Patch

diff --git a/drivers/clk/clk-npcm7xx.c b/drivers/clk/clk-npcm7xx.c
index dba5384..740af90 100644
--- a/drivers/clk/clk-npcm7xx.c
+++ b/drivers/clk/clk-npcm7xx.c
@@ -555,7 +555,7 @@  static void __init npcm7xx_clk_init(struct device_node *clk_np)
 	}
 
 	clk_base = ioremap(res.start, resource_size(&res));
-	if (IS_ERR(clk_base))
+	if (!clk_base)
 		goto npcm7xx_init_error;
 
 	npcm7xx_clk_data = kzalloc(sizeof(*npcm7xx_clk_data->hws) *