mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
phy: fsl-imx8mq-usb: fix typec switch leak on probe error path
If probe fails after imx95_usb_phy_get_tca() succeeds, the typec
switch leaks because the only cleanup path was in .remove(), which
never runs on probe failure.
Use devm_add_action_or_reset() so the switch is cleaned up on both
probe failure and driver removal. The imx95_usb_phy_put_tca() is no
longer needed, it will be removed in .remove() too.
Fixes: b58f0f86fd ("phy: fsl-imx8mq-usb: add tca function driver for imx95")
Cc: stable@vger.kernel.org
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://patch.msgid.link/20260731-imx8mp-usb-phy-improvement-v8-1-2ec8d6b3854d@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
9583243a52
commit
87a1805b1c
|
|
@ -173,9 +173,9 @@ static struct typec_switch_dev *tca_blk_get_typec_switch(struct platform_device
|
|||
return sw;
|
||||
}
|
||||
|
||||
static void tca_blk_put_typec_switch(struct typec_switch_dev *sw)
|
||||
static void tca_blk_put_typec_switch(void *data)
|
||||
{
|
||||
typec_switch_unregister(sw);
|
||||
typec_switch_unregister(data);
|
||||
}
|
||||
|
||||
static void tca_blk_orientation_set(struct tca_blk *tca,
|
||||
|
|
@ -248,6 +248,7 @@ static struct tca_blk *imx95_usb_phy_get_tca(struct platform_device *pdev,
|
|||
struct device *dev = &pdev->dev;
|
||||
struct resource *res;
|
||||
struct tca_blk *tca;
|
||||
int ret;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
||||
if (!res)
|
||||
|
|
@ -266,19 +267,13 @@ static struct tca_blk *imx95_usb_phy_get_tca(struct platform_device *pdev,
|
|||
tca->orientation = TYPEC_ORIENTATION_NORMAL;
|
||||
tca->sw = tca_blk_get_typec_switch(pdev, imx_phy);
|
||||
|
||||
ret = devm_add_action_or_reset(&pdev->dev, tca_blk_put_typec_switch, tca->sw);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
return tca;
|
||||
}
|
||||
|
||||
static void imx95_usb_phy_put_tca(struct imx8mq_usb_phy *imx_phy)
|
||||
{
|
||||
struct tca_blk *tca = imx_phy->tca;
|
||||
|
||||
if (!tca)
|
||||
return;
|
||||
|
||||
tca_blk_put_typec_switch(tca->sw);
|
||||
}
|
||||
|
||||
static u32 phy_tx_vref_tune_from_property(u32 percent)
|
||||
{
|
||||
percent = clamp(percent, 94U, 124U);
|
||||
|
|
@ -741,9 +736,7 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
|
|||
|
||||
static void imx8mq_usb_phy_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct imx8mq_usb_phy *imx_phy = platform_get_drvdata(pdev);
|
||||
|
||||
imx95_usb_phy_put_tca(imx_phy);
|
||||
}
|
||||
|
||||
static struct platform_driver imx8mq_usb_phy_driver = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user