Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1658043 > unrolled thread

re: phy: cpcap-usb: Add CPCAP PMIC USB support

Started byColin Ian King <colin.king@canonical.com>
First post2017-06-05 20:00 +0200
Last post2017-06-06 13:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  re: phy: cpcap-usb: Add CPCAP PMIC USB support Colin Ian King <colin.king@canonical.com> - 2017-06-05 20:00 +0200
    Re: phy: cpcap-usb: Add CPCAP PMIC USB support Tony Lindgren <tony@atomide.com> - 2017-06-06 13:00 +0200

#1658043 — re: phy: cpcap-usb: Add CPCAP PMIC USB support

FromColin Ian King <colin.king@canonical.com>
Date2017-06-05 20:00 +0200
Subjectre: phy: cpcap-usb: Add CPCAP PMIC USB support
Message-ID<tP4sh-61H-13@gated-at.bofh.it>
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.

[toc] | [next] | [standalone]


#1658623

FromTony Lindgren <tony@atomide.com>
Date2017-06-06 13:00 +0200
Message-ID<tPknq-7Bq-53@gated-at.bofh.it>
In reply to#1658043
* 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web