All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: xhci: Fix a potential NULL pointer dereference
Date: Fri, 14 Aug 2015 14:15:36 +0200	[thread overview]
Message-ID: <201508141415.36132.marex@denx.de> (raw)
In-Reply-To: <1439554386-9406-1-git-send-email-s.temerkhanov@gmail.com>

On Friday, August 14, 2015 at 02:13:06 PM, Sergey Temerkhanov wrote:
> This patch fixes a potential NULL pointer dereference arising on
> non-present/non-initialized xHCI controllers

Hi,

can you please explain how can such a condition even happen ?
I believe the hcor must always be inited at that point. What
is the condition which triggers this ?

> Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
> Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
> ---
> 
>  drivers/usb/host/xhci.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 0b09643..a6c6659 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -199,7 +199,7 @@ int xhci_reset(struct xhci_hcor *hcor)
>  	int ret;
> 
>  	/* Halting the Host first */
> -	debug("// Halt the HC\n");
> +	debug("// Halt the HC: %p\n", hcor);
>  	state = xhci_readl(&hcor->or_usbsts) & STS_HALT;
>  	if (!state) {
>  		cmd = xhci_readl(&hcor->or_usbcmd);
> @@ -1093,9 +1093,11 @@ int usb_lowlevel_stop(int index)
>  {
>  	struct xhci_ctrl *ctrl = (xhcic + index);
> 
> -	xhci_lowlevel_stop(ctrl);
> -	xhci_hcd_stop(index);
> -	xhci_cleanup(ctrl);
> +	if (ctrl->hcor) {
> +		xhci_lowlevel_stop(ctrl);
> +		xhci_hcd_stop(index);
> +		xhci_cleanup(ctrl);
> +	}
> 
>  	return 0;
>  }

Best regards,
Marek Vasut

  reply	other threads:[~2015-08-14 12:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14 12:13 [U-Boot] [PATCH] usb: xhci: Fix a potential NULL pointer dereference Sergey Temerkhanov
2015-08-14 12:15 ` Marek Vasut [this message]
2015-08-14 13:00   ` Sergei Temerkhanov
2015-08-14 13:44     ` Marek Vasut
2015-08-14 14:29       ` Sergei Temerkhanov
2015-08-14 14:45         ` Marek Vasut
2015-08-14 14:52           ` Sergei Temerkhanov

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=201508141415.36132.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.