All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Peter Chen <peter.chen@nxp.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: [1/1] usb: chipidea: fix static checker warning for NULL pointer
Date: Thu, 17 Jan 2019 11:58:43 +0100	[thread overview]
Message-ID: <20190117105843.GB28882@kroah.com> (raw)

On Thu, Jan 17, 2019 at 09:24:20AM +0000, Peter Chen wrote:
> During the static checker, "data->usbmisc_data" may be NULL.

I can not quite parse this sentance.  Do you mean that a static checker
found this issue?

> Fix it by adding this pointer judgement before using.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> ---
>  drivers/usb/chipidea/ci_hdrc_imx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index e81de9ca8729..9b45aa422e69 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -316,7 +316,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->usbmisc_data))
>  		return PTR_ERR(data->usbmisc_data);
>  
> -	if (of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) {
> +	if ((of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC)
> +		&& data->usbmisc_data) {

Are you sure that is correct?  If usbmisc_data is NULL, then you just
took out a bunch of checking and lookups.  Don't you normally need to do
this even if that pointer is NULL?

Will the rest of the function still work properly if that is the case?

thanks,

greg k-h

             reply	other threads:[~2019-01-17 10:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 10:58 Greg Kroah-Hartman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-01-18  1:35 [1/1] usb: chipidea: fix static checker warning for NULL pointer Peter Chen
2019-01-17  9:24 Peter Chen
2018-12-24  1:18 Peter Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190117105843.GB28882@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.