Skip to content

Commit

Permalink
usb: chipidea: usbmisc_imx: fix a possible NULL dereference
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Peter Chen <[email protected]>
  • Loading branch information
montjoie authored and Peter Chen committed Nov 18, 2015
1 parent 85da852 commit 090bc26
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/usb/chipidea/usbmisc_imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 090bc26

Please sign in to comment.