Commit 4a0c4c36 authored by Alexandre Belloni's avatar Alexandre Belloni Committed by Greg Kroah-Hartman

USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq

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: e4df9227 (USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe)
Reported-by: default avatarPeter Rosin <peda@axentia.se>
Tested-by: default avatarPeter Rosin <peda@axentia.se>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: stable@vger.kernel.org # 4.3+
Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6406eeb3
...@@ -473,6 +473,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) ...@@ -473,6 +473,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
if (!pdata) if (!pdata)
return -ENOMEM; return -ENOMEM;
pdev->dev.platform_data = pdata;
if (!of_property_read_u32(np, "num-ports", &ports)) if (!of_property_read_u32(np, "num-ports", &ports))
pdata->ports = ports; pdata->ports = ports;
...@@ -483,6 +485,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) ...@@ -483,6 +485,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
*/ */
if (i >= pdata->ports) { if (i >= pdata->ports) {
pdata->vbus_pin[i] = -EINVAL; pdata->vbus_pin[i] = -EINVAL;
pdata->overcurrent_pin[i] = -EINVAL;
continue; continue;
} }
...@@ -513,10 +516,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) ...@@ -513,10 +516,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
} }
at91_for_each_port(i) { at91_for_each_port(i) {
if (i >= pdata->ports) { if (i >= pdata->ports)
pdata->overcurrent_pin[i] = -EINVAL; break;
continue;
}
pdata->overcurrent_pin[i] = pdata->overcurrent_pin[i] =
of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags); 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) ...@@ -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); device_init_wakeup(&pdev->dev, 1);
return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment