Commit 51ef74f6400c731827454d010b35b122103fe9f9

Authored by Julia Lawall
Committed by Felipe Balbi
1 parent 272b05a988

usb: musb: dsps: fix devm_ioremap_resource error detection code

devm_ioremap_resource returns an ERR_PTR value, not NULL, on failure.
Furthermore, the value returned by devm_ioremap_resource should be tested.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
statement S;
@@

*e = devm_ioremap_resource(...);
if (!e1) S

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Felipe Balbi <balbi@ti.com>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

drivers/usb/musb/musb_dsps.c
... ... @@ -361,8 +361,8 @@
361 361 return -EINVAL;
362 362  
363 363 reg_base = devm_ioremap_resource(dev, r);
364   - if (!musb->ctrl_base)
365   - return -EINVAL;
  364 + if (IS_ERR(reg_base))
  365 + return PTR_ERR(reg_base);
366 366 musb->ctrl_base = reg_base;
367 367  
368 368 /* NOP driver needs change if supporting dual instance */