usb: chipidea: imx: fix a possible NULL dereference
PATCH 1/2 usb: chipidea: 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 <[email protected]>
--- drivers/usb/chipidea/usbmisc_imx.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +6 -4
@@ -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 ;
Signature · 1 line
2.4.10
PATCH 2/2 usb: chipidea: imx: fix a possible NULL dereference
of_match_device could return NULL, and so cause a NULL pointer dereference later.
Reported-by coverity (CID 1324138)
Signed-off-by LABBE Corentin <[email protected]>
--- drivers/usb/chipidea/ci_hdrc_imx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +8 -3
@@ -145,9 +145,14 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) .flags = CI_HDRC_SET_NON_ZERO_TTHA, };int ret; -const struct of_device_id *of_id = -of_match_device (ci_hdrc_imx_dt_ids, &pdev->dev); -const struct ci_hdrc_imx_platform_flag *imx_platform_flag = of_id->data; +const struct of_device_id *of_id; +const struct ci_hdrc_imx_platform_flag *imx_platform_flag; + + of_id =of_match_device (ci_hdrc_imx_dt_ids, &pdev->dev); +if (!of_id) +return -ENODEV ; + + imx_platform_flag = of_id->data; data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data)
Signature · 1 line
2.4.10