diff options
author | LABBE Corentin <clabbe.montjoie@gmail.com> | 2015-11-12 08:43:33 +0100 |
---|---|---|
committer | Peter Chen <peter.chen@freescale.com> | 2015-11-18 15:27:12 +0800 |
commit | 090bc267ea1013bbb33778b343b4acd78b9c5d9b (patch) | |
tree | 8ca3e39ef4e034b5f4fa1907bd43030819b9a75d /drivers/usb/chipidea | |
parent | 85da852df66e5e0d3aba761b0fece7c958ff0685 (diff) | |
download | linux-090bc267ea1013bbb33778b343b4acd78b9c5d9b.tar.gz linux-090bc267ea1013bbb33778b343b4acd78b9c5d9b.tar.bz2 linux-090bc267ea1013bbb33778b343b4acd78b9c5d9b.zip |
usb: chipidea: usbmisc_imx: fix a possible NULL dereference
of_match_device could return NULL, and so cause a NULL pointer
dereference later. Renaming tmp_dev to of_id (like all others do) in the
process.
Reported-by: coverity (CID 1324135)
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Diffstat (limited to 'drivers/usb/chipidea')
-rw-r--r-- | drivers/usb/chipidea/usbmisc_imx.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index fcea4eb36eee..ab8b027e8cc8 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -500,7 +500,11 @@ static int usbmisc_imx_probe(struct platform_device *pdev) { struct resource *res; struct imx_usbmisc *data; - struct of_device_id *tmp_dev; + const struct of_device_id *of_id; + + of_id = of_match_device(usbmisc_imx_dt_ids, &pdev->dev); + if (!of_id) + return -ENODEV; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -513,9 +517,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev) if (IS_ERR(data->base)) return PTR_ERR(data->base); - tmp_dev = (struct of_device_id *) - of_match_device(usbmisc_imx_dt_ids, &pdev->dev); - data->ops = (const struct usbmisc_ops *)tmp_dev->data; + data->ops = (const struct usbmisc_ops *)of_id->data; platform_set_drvdata(pdev, data); return 0; |