All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Albert Wang <albertccwang@google.com>
Cc: balbi@kernel.org, quic_jackp@quicinc.com, badhri@google.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: dwc3: gadget: Fix null pointer dereference
Date: Wed, 4 May 2022 16:35:15 +0200	[thread overview]
Message-ID: <YnKPI4O7JloBqi0F@kroah.com> (raw)
In-Reply-To: <20220504072802.83487-1-albertccwang@google.com>

On Wed, May 04, 2022 at 03:28:02PM +0800, Albert Wang wrote:
> There are still race conditions to hit the null pointer deference
> with my previous commit. So I re-write the code to dereference the
> pointer right after checking it is not null.

What race conditions?

And just moving it is not going to solve a race condition, you need a
lock.

> 
> Fixes: 26288448120b ("usb: dwc3: gadget: Fix null pointer exception")
> 
> Signed-off-by: Albert Wang <albertccwang@google.com>
> ---
>  drivers/usb/dwc3/gadget.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 19477f4bbf54..f2792968afd9 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -3366,15 +3366,14 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
>  	struct dwc3		*dwc = dep->dwc;
>  	bool			no_started_trb = true;
>  
> -	if (!dep->endpoint.desc)
> -		return no_started_trb;
> -
>  	dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
>  
>  	if (dep->flags & DWC3_EP_END_TRANSFER_PENDING)
>  		goto out;
>  
> -	if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
> +	if (!dep->endpoint.desc)
> +		return no_started_trb;
> +	else if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&

There is no locking here, so why would this change do anything but
reduce the window?

thanks,

greg k-h

  reply	other threads:[~2022-05-04 14:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  7:28 [PATCH] usb: dwc3: gadget: Fix null pointer dereference Albert Wang
2022-05-04 14:35 ` Greg KH [this message]
2022-05-11 16:30   ` Jack Pham

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=YnKPI4O7JloBqi0F@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=albertccwang@google.com \
    --cc=badhri@google.com \
    --cc=balbi@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_jackp@quicinc.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.