diff options
author | LABBE Corentin <clabbe.montjoie@gmail.com> | 2015-11-24 09:34:09 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-12-08 09:13:28 -0500 |
commit | 928c75fbeb6b62edbdff7c52ee1e9a3591faee4f (patch) | |
tree | 74a4b331f38f97eff8615c5af2c6dea8620023b0 | |
parent | 62e345ae5b6ed977b02c24d1eaeaece062f9fb17 (diff) |
usb: phy: msm: fix a possible NULL dereference
of_match_device could return NULL, and so cause a NULL pointer
dereference later.
Even if the probability of this case is very low, fixing it made
static analyzers happy.
Solving this with of_device_get_match_data made also code simplier.
Reported-by: coverity (CID 1324133)
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/phy/phy-msm-usb.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 80eb991c2506..0d19a6d61a71 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c | |||
@@ -1506,7 +1506,6 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1506 | { | 1506 | { |
1507 | struct msm_otg_platform_data *pdata; | 1507 | struct msm_otg_platform_data *pdata; |
1508 | struct extcon_dev *ext_id, *ext_vbus; | 1508 | struct extcon_dev *ext_id, *ext_vbus; |
1509 | const struct of_device_id *id; | ||
1510 | struct device_node *node = pdev->dev.of_node; | 1509 | struct device_node *node = pdev->dev.of_node; |
1511 | struct property *prop; | 1510 | struct property *prop; |
1512 | int len, ret, words; | 1511 | int len, ret, words; |
@@ -1518,8 +1517,9 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1518 | 1517 | ||
1519 | motg->pdata = pdata; | 1518 | motg->pdata = pdata; |
1520 | 1519 | ||
1521 | id = of_match_device(msm_otg_dt_match, &pdev->dev); | 1520 | pdata->phy_type = (enum msm_usb_phy_type)of_device_get_match_data(&pdev->dev); |
1522 | pdata->phy_type = (enum msm_usb_phy_type) id->data; | 1521 | if (!pdata->phy_type) |
1522 | return 1; | ||
1523 | 1523 | ||
1524 | motg->link_rst = devm_reset_control_get(&pdev->dev, "link"); | 1524 | motg->link_rst = devm_reset_control_get(&pdev->dev, "link"); |
1525 | if (IS_ERR(motg->link_rst)) | 1525 | if (IS_ERR(motg->link_rst)) |