linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Bin Liu <b-liu@ti.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()
Date: Wed, 11 Dec 2019 17:10:17 +0800	[thread overview]
Message-ID: <dc1cbf76-a2c4-a861-0847-d3434b843fee@gmail.com> (raw)
In-Reply-To: <20191211080910.GA426347@kroah.com>



On 2019/12/11 16:09, Greg Kroah-Hartman wrote:
> On Tue, Dec 10, 2019 at 10:54:54AM -0600, Bin Liu wrote:
>> From: Jia-Ju Bai <baijiaju1990@gmail.com>
>>
>> In musb_handle_intr_connect(), there is an if statement on line 783 to
>> check whether musb->hcd is NULL:
>>      if (musb->hcd)
>>
>> When musb->hcd is NULL, it is used on line 797:
>>      musb_host_poke_root_hub(musb);
>>          if (musb->hcd->status_urb)
>>
>> Thus, a possible null-pointer dereference may occur.
> Maybe, if musb->hcd really ever could be NULL.
>
> In looking at the code, I don't see where that could happen, do you?
> Why is that check there in the first place?
>
> What sets musb->hcd to NULL in the first place?

In fact, my static analysis tool identifies an if check about musb->hcd, 
so it infers that musb->hcd could be NULL here.
But it does not try to find any explicit place that set musb->hcd to NULL.

If musb->hcd is never NULL here, we can just delete the related if check.


Best wishes,
Jia-Ju Bai

  reply	other threads:[~2019-12-11  9:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10 16:54 [PATCH 0/2] musb fixes for v5.5-rc2 Bin Liu
2019-12-10 16:54 ` [PATCH 1/2] usb: musb: sunxi: propagate devicetree node to glue pdev Bin Liu
2019-12-11  8:05   ` Greg Kroah-Hartman
2019-12-11  8:49     ` Johan Hovold
2019-12-11  8:51       ` Greg Kroah-Hartman
2019-12-11  8:53         ` Johan Hovold
2019-12-10 16:54 ` [PATCH 2/2] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect() Bin Liu
2019-12-11  8:09   ` Greg Kroah-Hartman
2019-12-11  9:10     ` Jia-Ju Bai [this message]
2019-12-11  9:20       ` Greg Kroah-Hartman
2019-12-17  8:26         ` Jia-Ju Bai

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=dc1cbf76-a2c4-a861-0847-d3434b843fee@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=b-liu@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).