]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: cdns3: plat: fix leaked role switch on core role initialization failure
authorPeter Chen <peter.chen@cixtech.com>
Thu, 14 May 2026 01:01:14 +0000 (09:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 May 2026 09:34:44 +0000 (11:34 +0200)
Calling usb_role_switch_unregister if core role initialization failure.

Fixes: e4d7362dc9cd ("usb: cdns3: Add USBSSP platform driver support")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-devicetree/agKaEePSFknhDBg2@nchen-desktop/T/#m21e1d9c1574eb127ce03c0c2a1a49002ce435b52
Signed-off-by: Peter Chen <peter.chen@cixtech.com>
Link: https://patch.msgid.link/20260514010114.2436781-2-peter.chen@cixtech.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/cdns3/cdns3-plat.c

index 3fe3109a3688adf3904fdce036ae664fd88c17e9..91159910fe95f009dff1ac377430374d6f44fd4f 100644 (file)
@@ -167,7 +167,7 @@ static int cdns3_plat_probe(struct platform_device *pdev)
        cdns->host_init = cdns3_plat_host_init;
        ret = cdns_core_init_role(cdns);
        if (ret)
-               goto err_cdns_init;
+               goto err_cdns_init_role;
 
        device_set_wakeup_capable(dev, true);
        pm_runtime_set_active(dev);
@@ -186,6 +186,9 @@ static int cdns3_plat_probe(struct platform_device *pdev)
 
        return 0;
 
+err_cdns_init_role:
+       if (cdns->role_sw)
+               usb_role_switch_unregister(cdns->role_sw);
 err_cdns_init:
        set_phy_power_off(cdns);
 err_phy_power_on: