usb: dwc3: core: cope with NULL pdata
authorFelipe Balbi <balbi@ti.com>
Wed, 14 Aug 2013 18:21:23 +0000 (13:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2013 19:23:09 +0000 (12:23 -0700)
if pdata is a NULL pointer we could cause a
kernel oops when probing the driver. Make sure
to cope with systems which won't pass pdata
to the driver.

Tested-by: Paul Zimmerman <paulz@synopsys.com>
Reported-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/core.c

index 3ff6f0ad01df2d85b8a3c196855fc85fa39e0490..577af1b237f2c3b279384e2323e9ae80e97234db 100644 (file)
@@ -393,7 +393,7 @@ static int dwc3_probe(struct platform_device *pdev)
 
                dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
                dwc->dr_mode = of_usb_get_dr_mode(node);
-       } else {
+       } else if (pdata) {
                dwc->maximum_speed = pdata->maximum_speed;
 
                dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
@@ -401,6 +401,9 @@ static int dwc3_probe(struct platform_device *pdev)
 
                dwc->needs_fifo_resize = pdata->tx_fifo_resize;
                dwc->dr_mode = pdata->dr_mode;
+       } else {
+               dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+               dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
        }
 
        /* default to superspeed if no maximum_speed passed */