public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: phy: add missing put_device() call in tegra_usb_phy_parse_pmc()
@ 2021-12-07 12:56 Qing Wang
  2021-12-07 14:11 ` Dmitry Osipenko
  0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-12-07 12:56 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	linux-usb, linux-tegra, linux-kernel
  Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

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

Add a jump target to fix the exception handling for this 
function implementation.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/usb/phy/phy-tegra-usb.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 68cd4b6..5678b7f
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -1300,18 +1300,26 @@ static int tegra_usb_phy_parse_pmc(struct device *dev,
 	err = devm_add_action_or_reset(dev, tegra_usb_phy_put_pmc_device,
 				       &pmc_pdev->dev);
 	if (err)
-		return err;
+		goto error_put_device;
 
-	if (!platform_get_drvdata(pmc_pdev))
-		return -EPROBE_DEFER;
+	if (!platform_get_drvdata(pmc_pdev)) {
+		err = -EPROBE_DEFER;
+		goto error_put_device;
+	}
 
 	phy->pmc_regmap = dev_get_regmap(&pmc_pdev->dev, "usb_sleepwalk");
-	if (!phy->pmc_regmap)
-		return -EINVAL;
+	if (!phy->pmc_regmap) {
+		err = -EINVAL;
+		goto error_put_device;
+	}
 
 	phy->instance = args.args[0];
 
 	return 0;
+
+error_put_device:
+	put_device(&pmc_pdev->dev);
+	return err;
 }
 
 static const struct tegra_phy_soc_config tegra20_soc_config = {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-07 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-07 12:56 [PATCH] usb: phy: add missing put_device() call in tegra_usb_phy_parse_pmc() Qing Wang
2021-12-07 14:11 ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox