From: Wu Liang feng Date: Thu, 25 Aug 2016 12:37:33 +0000 (+0800) Subject: usb: dwc3: fix possible NULL pointer dereference for rockchip plat X-Git-Tag: firefly_0821_release~1626 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7b9548efe612efbeac5ed58e088d34b4d61d861c;p=firefly-linux-kernel-4.4.55.git usb: dwc3: fix possible NULL pointer dereference for rockchip plat Change-Id: I2afb1fa38ae6e76b8db397bda59fd9fbafe9a53b Signed-off-by: Wu Liang feng --- diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c index b18851443536..744e0e171273 100644 --- a/drivers/usb/dwc3/dwc3-rockchip.c +++ b/drivers/usb/dwc3/dwc3-rockchip.c @@ -80,6 +80,9 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work) int ret; u32 reg; + if (!dwc) + return; + if (extcon_get_cable_state_(edev, EXTCON_USB) > 0) { if (dwc->connected) return; @@ -318,6 +321,11 @@ static int dwc3_rockchip_probe(struct platform_device *pdev) } rockchip->dwc = platform_get_drvdata(child_pdev); + if (!rockchip->dwc) { + dev_err(dev, "failed to get drvdata dwc3\n"); + ret = -ENODEV; + goto err3; + } if (rockchip->edev) { pm_runtime_set_autosuspend_delay(&child_pdev->dev,