SUPERH platform development
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH] usb: renesas_usbhs: fix NULL pointer dereference in dma_release_channel()
Date: Fri, 30 Jan 2015 13:38:28 +0000	[thread overview]
Message-ID: <20150130133828.GD31922@verge.net.au> (raw)
In-Reply-To: <1422601103-1144-1-git-send-email-yoshihiro.shimoda.uh@renesas.com>

On Fri, Jan 30, 2015 at 03:58:23PM +0900, Yoshihiro Shimoda wrote:
> This patch fixes an issue that the following commit causes NULL
> pointer dereference in dma_release_channel().
>  "usb: renesas_usbhs: add support for requesting DT DMA"
>  (commit id abd2dbf6bb1b5f3a03a8c76b1a8879da1dd30caa)
> 
> The usbhsf_dma_init_dt() should set fifo->{t,r}x_chan to NULL if
> dma_request_slave_channel_reason() returns IS_ERR value.
> Otherwise, usbhsf_dma_quit() will call dma_release_channel(), and then
> NULL pointer dereference happens.
> 
> Reported-by: Simon Horman <horms@verge.net.au>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

I have tested this on the lager and koelsch boards using
shmobile_defconfig and next-20150129 as a base. The environment
where I originally observed the problem.

Tested-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> This patch is based on Felipe's usb.git / testing/next branch.
> (commit id }b3990cb707ff91cd6507d53a0a730afe97)
> 
>  drivers/usb/renesas_usbhs/fifo.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
> index 4c086b1..d891bff 100644
> --- a/drivers/usb/renesas_usbhs/fifo.c
> +++ b/drivers/usb/renesas_usbhs/fifo.c
> @@ -1072,7 +1072,11 @@ static void usbhsf_dma_init_pdev(struct usbhs_fifo *fifo)
>  static void usbhsf_dma_init_dt(struct device *dev, struct usbhs_fifo *fifo)
>  {
>  	fifo->tx_chan = dma_request_slave_channel_reason(dev, "tx");
> +	if (IS_ERR(fifo->tx_chan))
> +		fifo->tx_chan = NULL;
>  	fifo->rx_chan = dma_request_slave_channel_reason(dev, "rx");
> +	if (IS_ERR(fifo->rx_chan))
> +		fifo->rx_chan = NULL;
>  }
>  
>  static void usbhsf_dma_init(struct usbhs_priv *priv,
> -- 
> 1.7.9.5
> 

  parent reply	other threads:[~2015-01-30 13:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30  6:58 [PATCH] usb: renesas_usbhs: fix NULL pointer dereference in dma_release_channel() Yoshihiro Shimoda
2015-01-30  9:59 ` Geert Uytterhoeven
2015-01-30 13:38 ` Simon Horman [this message]
2015-02-02  5:40 ` yoshihiro shimoda
2015-02-02  6:03 ` yoshihiro shimoda

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=20150130133828.GD31922@verge.net.au \
    --to=horms@verge.net.au \
    --cc=linux-sh@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