Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1650782

[PATCH 1/3] phy: twl4030-usb: undo usb_add_phy_dev in error path

From Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Newsgroups linux.kernel
Subject [PATCH 1/3] phy: twl4030-usb: undo usb_add_phy_dev in error path
Date 2017-05-25 22:00 +0200
Message-ID <tL75o-40J-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


usb_add_phy_dev adds the passed phy to a list. When twl4030_usb_probe
fails this must be undone otherwise this results in a use after free
when the list is travered the next time.

Fixes: 6747caa76cab ("usb: phy: twl4030: use the new generic PHY framework")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/phy/phy-twl4030-usb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 2990b3965460..07cb0150d008 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -750,13 +750,16 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 	if (status < 0) {
 		dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
 			twl->irq, status);
+		usb_remove_phy(&twl->phy);
 		return status;
 	}
 
 	if (pdata)
 		err = phy_create_lookup(phy, "usb", "musb-hdrc.0");
-	if (err)
+	if (err) {
+		usb_remove_phy(&twl->phy);
 		return err;
+	}
 
 	pm_runtime_mark_last_busy(&pdev->dev);
 	pm_runtime_put_autosuspend(twl->dev);
-- 
2.11.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] phy: twl4030-usb: undo usb_add_phy_dev in error path Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-05-25 22:00 +0200
  [PATCH 2/3] phy: twl4030-usb: handle usb_add_phy_dev return value Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-05-25 22:00 +0200
  [PATCH 3/3] phy: twl4030-usb: propagate actual error on regulator lookup Uwe Kleine-König          <u.kleine-koenig@pengutronix.de> - 2017-05-25 22:00 +0200

csiph-web