summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLABBE Corentin <clabbe.montjoie@gmail.com>2015-11-12 07:43:34 (GMT)
committerPeter Chen <peter.chen@freescale.com>2015-11-18 07:27:31 (GMT)
commit6f51bc340d2a1c71a2409f80f3e60fe2c44e35ae (patch)
treebb6567c869fe3efae232e9f48204b9978e938efa
parent090bc267ea1013bbb33778b343b4acd78b9c5d9b (diff)
downloadlinux-6f51bc340d2a1c71a2409f80f3e60fe2c44e35ae.tar.xz
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 <clabbe.montjoie@gmail.com> Signed-off-by: Peter Chen <peter.chen@freescale.com>
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 7c9b630..5a048b7 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -247,9 +247,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)