From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq
Date: Thu, 3 Dec 2015 09:43:20 +0100 [thread overview]
Message-ID: <566000A8.7070107@atmel.com> (raw)
In-Reply-To: <1449085015-5538-1-git-send-email-alexandre.belloni@free-electrons.com>
Le 02/12/2015 20:36, Alexandre Belloni a ?crit :
> The interrupt handler, ohci_hcd_at91_overcurrent_irq may be called right
> after registration. At that time, pdev->dev.platform_data is not yet set,
> leading to a NULL pointer dereference.
>
> Fixes: e4df92279fd9 (USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe)
Yes, with:
Cc: stable at vger.kernel.org # 4.3+
> Reported-by: Peter Rosin <peda@axentia.se>
> Tested-by: Peter Rosin <peda@axentia.se>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Alan, I think it's a good candidate to enter the 4.4-rcX...
Thanks, bye.
> ---
> drivers/usb/host/ohci-at91.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 342ffd140122..8c6e15bd6ff0 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -473,6 +473,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
> if (!pdata)
> return -ENOMEM;
>
> + pdev->dev.platform_data = pdata;
> +
> if (!of_property_read_u32(np, "num-ports", &ports))
> pdata->ports = ports;
>
> @@ -483,6 +485,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
> */
> if (i >= pdata->ports) {
> pdata->vbus_pin[i] = -EINVAL;
> + pdata->overcurrent_pin[i] = -EINVAL;
> continue;
> }
>
> @@ -513,10 +516,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
> }
>
> at91_for_each_port(i) {
> - if (i >= pdata->ports) {
> - pdata->overcurrent_pin[i] = -EINVAL;
> - continue;
> - }
> + if (i >= pdata->ports)
> + break;
>
> pdata->overcurrent_pin[i] =
> of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
> @@ -552,8 +553,6 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
> }
> }
>
> - pdev->dev.platform_data = pdata;
> -
> device_init_wakeup(&pdev->dev, 1);
> return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
> }
>
--
Nicolas Ferre
next prev parent reply other threads:[~2015-12-03 8:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-02 19:36 [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq Alexandre Belloni
2015-12-03 8:43 ` Nicolas Ferre [this message]
2015-12-03 15:25 ` Alan Stern
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=566000A8.7070107@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=linux-arm-kernel@lists.infradead.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).