Skip to contentSkip to conversation

usb: phy: phy-mxs-usb: fix a possible NULL dereference

PATCH Superseded LABBE Corentin 1 participant 1 message Nov 12, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: phy: phy-mxs-usb: fix a possible NULL dereference

of_match_device could return NULL, and so cause a NULL pointer dereference later.

---
 drivers/usb/phy/phy-mxs-usb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +5 -2
index 4d863eb..b7536af 100644
@@ -452,10 +452,13 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	struct clk *clk;
 	struct mxs_phy *mxs_phy;
 	int ret;
-	const struct of_device_id *of_id =
-			of_match_device(mxs_phy_dt_ids, &pdev->dev);
+	const struct of_device_id *of_id;
 	struct device_node *np = pdev->dev.of_node;
 
+	of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev);
+	if (!of_id)
+		return -ENODEV;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(base))
Signature · 1 line
2.4.10