usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
authorLi Yang <lidaxian@hust.edu.cn>
Thu, 20 Apr 2023 14:08:31 +0000 (22:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 29 May 2023 14:49:16 +0000 (15:49 +0100)
Smatch reports:
drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
warn: missing unwind goto?

After geting irq, if ret < 0, it will return without error handling to
free memory.
Just add error handling to fix this problem.

Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230420140832.9110-1-lidaxian@hust.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/phy/phy-tahvo.c

index 47562d49dfc1b8958f6f18db841e47d5f410a90a..5cac31c6029b38da9f2488fbfdaa340b28a2d5b6 100644 (file)
@@ -391,7 +391,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
 
        tu->irq = ret = platform_get_irq(pdev, 0);
        if (ret < 0)
-               return ret;
+               goto err_remove_phy;
        ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt,
                                   IRQF_ONESHOT,
                                   "tahvo-vbus", tu);