All of lore.kernel.org
 help / color / mirror / Atom feed
* re: phy: cpcap-usb: Add CPCAP PMIC USB support
@ 2017-06-05 17:54 Colin Ian King
  2017-06-06 10:54 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2017-06-05 17:54 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Andrew Lunn, Florian Fainelli, netdev, linux-kernel

Hi Tony,

While running static analysis on linux-next, CoverityScan picked up a
NULL pointer deference on ddata->pins when calling pinctrl_lookup_state:

466        ddata->pins = devm_pinctrl_get(ddata->dev);

   1. Condition IS_ERR(ddata->pins), taking true branch.

467        if (IS_ERR(ddata->pins)) {
468                dev_info(ddata->dev, "default pins not configured:
%ld\n",
469                         PTR_ERR(ddata->pins));

   2. assign_zero: Assigning: ddata->pins = NULL.

470                ddata->pins = NULL;
471        }
472

   CID 1440453 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)3.
var_deref_model: Passing null pointer ddata->pins to
pinctrl_lookup_state, which dereferences it. [show details]

473        ddata->pins_ulpi = pinctrl_lookup_state(ddata->pins, "ulpi");


I suspect the IS_ERROR() check should return with some error return
rather than continuing.

Colin.

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

* Re: phy: cpcap-usb: Add CPCAP PMIC USB support
  2017-06-05 17:54 phy: cpcap-usb: Add CPCAP PMIC USB support Colin Ian King
@ 2017-06-06 10:54 ` Tony Lindgren
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2017-06-06 10:54 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Andrew Lunn, Florian Fainelli, netdev, linux-kernel

* Colin Ian King <colin.king@canonical.com> [170605 10:58]:
> Hi Tony,
> 
> While running static analysis on linux-next, CoverityScan picked up a
> NULL pointer deference on ddata->pins when calling pinctrl_lookup_state:
> 
> 466        ddata->pins = devm_pinctrl_get(ddata->dev);
> 
>    1. Condition IS_ERR(ddata->pins), taking true branch.
> 
> 467        if (IS_ERR(ddata->pins)) {
> 468                dev_info(ddata->dev, "default pins not configured:
> %ld\n",
> 469                         PTR_ERR(ddata->pins));
> 
>    2. assign_zero: Assigning: ddata->pins = NULL.
> 
> 470                ddata->pins = NULL;
> 471        }
> 472
> 
>    CID 1440453 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)3.
> var_deref_model: Passing null pointer ddata->pins to
> pinctrl_lookup_state, which dereferences it. [show details]
> 
> 473        ddata->pins_ulpi = pinctrl_lookup_state(ddata->pins, "ulpi");
> 
> 
> I suspect the IS_ERROR() check should return with some error return
> rather than continuing.

OK thanks for letting me know. I'll take a look and will
send a patch. The pinctrl_lookup_state() probably need to
happen only if ddata->pins as they are optional.

Regards,

Tony

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

end of thread, other threads:[~2017-06-06 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 17:54 phy: cpcap-usb: Add CPCAP PMIC USB support Colin Ian King
2017-06-06 10:54 ` Tony Lindgren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.