Skip to contentSkip to conversation

phy: tegra: add missing put_device() call in tegra210_xusb_padctl_probe()

PATCH In review Qing Wang 2 participants 3 messages Dec 7, 2021

Subsystems (3)
lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 phy: tegra: add missing put_device() call in tegra210_xusb_padctl_probe()

From: Wang Qing <[email protected]>

of_find_device_by_node() takes a reference to the embedded struct device which needs to be dropped when error return.

---
 drivers/phy/tegra/xusb-tegra210.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb-tegra210.c +3 -1
index eedfc7c..05a0800
@@ -3170,8 +3170,10 @@ tegra210_xusb_padctl_probe(struct device *dev,
 		goto out;
 	}
 
-	if (!platform_get_drvdata(pdev))
+	if (!platform_get_drvdata(pdev)) {
+		put_device(&pdev->dev);
 		return ERR_PTR(-EPROBE_DEFER);
+	}
 
 	padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk");
 	if (!padctl->regmap)
Signature · 1 line
2.7.4
#1 lore raw

07.12.2021 15:56, Qing Wang пишет:

Quoted 17 lines

From: Wang Qing <[email protected]>

of_find_device_by_node() takes a reference to the embedded struct device which needs to be dropped when error return.

---
 drivers/phy/tegra/xusb-tegra210.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb-tegra210.c +0 -0
index eedfc7c..05a0800
@@ -3170,8 +3170,10 @@ tegra210_xusb_padctl_probe(struct device *dev,
 		goto out;

drivers/phy/tegra/xusb-tegra210.c tegra210_xusb_padctl_probe(struct device *dev, · line 3179

Quoted 10 lines
drivers/phy/tegra/xusb-tegra210.c +3 -1
 	}
 
-	if (!platform_get_drvdata(pdev))
+	if (!platform_get_drvdata(pdev)) {
+		put_device(&pdev->dev);
 		return ERR_PTR(-EPROBE_DEFER);
+	}
 
 	padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk");
 	if (!padctl->regmap)

What if dev_get_regmap() fails? What if driver is removed?

Please either fix it properly or don't fix it.

#2 lore raw

07.12.2021 17:35, Dmitry Osipenko пишет:

Quoted 25 lines

07.12.2021 15:56, Qing Wang пишет:

Quoted 24 lines

From: Wang Qing <[email protected]>

of_find_device_by_node() takes a reference to the embedded struct device which needs to be dropped when error return.

---
 drivers/phy/tegra/xusb-tegra210.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb-tegra210.c +3 -1
index eedfc7c..05a0800
@@ -3170,8 +3170,10 @@ tegra210_xusb_padctl_probe(struct device *dev,
 		goto out;
 	}
 
-	if (!platform_get_drvdata(pdev))
+	if (!platform_get_drvdata(pdev)) {
+		put_device(&pdev->dev);
 		return ERR_PTR(-EPROBE_DEFER);
+	}
 
Quoted 8 lines

drivers/phy/tegra/xusb-tegra210.c tegra210_xusb_padctl_probe(struct device *dev, · line 3179

Quoted 3 lines
drivers/phy/tegra/xusb-tegra210.c +0 -0
 	padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk");
 	if (!padctl->regmap)

What if dev_get_regmap() fails? What if driver is removed?

Please either fix it properly or don't fix it.

My bad, I see now in the code that this dev_get_regmap() fail is okay. Nevertheless the driver removal is incorrect.