Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1282297 > unrolled thread
| Started by | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| First post | 2015-12-02 20:40 +0100 |
| Last post | 2015-12-03 16:30 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-12-02 20:40 +0100
Re: [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq Nicolas Ferre <nicolas.ferre@atmel.com> - 2015-12-03 09:50 +0100
Re: [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq Alan Stern <stern@rowland.harvard.edu> - 2015-12-03 16:30 +0100
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2015-12-02 20:40 +0100 |
| Subject | [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq |
| Message-ID | <qBlpT-35b-5@gated-at.bofh.it> |
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)
Reported-by: Peter Rosin <peda@axentia.se>
Tested-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
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);
}
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Nicolas Ferre <nicolas.ferre@atmel.com> |
|---|---|
| Date | 2015-12-03 09:50 +0100 |
| Subject | Re: [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq |
| Message-ID | <qBxKp-2zO-1@gated-at.bofh.it> |
| In reply to | #1282297 |
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@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Alan Stern <stern@rowland.harvard.edu> |
|---|---|
| Date | 2015-12-03 16:30 +0100 |
| Message-ID | <qBDZw-6Ur-21@gated-at.bofh.it> |
| In reply to | #1282802 |
On Thu, 3 Dec 2015, Nicolas Ferre wrote: > 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@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... I agree. Greg, please merge this with a CC: stable tag added. Acked-by: Alan Stern <stern@rowland.harvard.edu> Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web