usb: phy: twl6030-usb: Fix a resource leak in an error handling path in 'twl6030_usb_...
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 27 Apr 2020 20:21:16 +0000 (22:21 +0200)
committerFelipe Balbi <balbi@kernel.org>
Sat, 9 May 2020 08:05:08 +0000 (11:05 +0300)
A call to 'regulator_get()' is hidden in 'twl6030_usb_ldo_init()'. A
corresponding put must be performed in the error handling path, as
already done in the remove function.

While at it, also move a 'free_irq()' call in the error handling path in
order to be consistent.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/phy/phy-twl6030-usb.c

index bfebf1f..9a7e655 100644 (file)
@@ -377,7 +377,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
        if (status < 0) {
                dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
                        twl->irq1, status);
-               return status;
+               goto err_put_regulator;
        }
 
        status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
@@ -386,8 +386,7 @@ static int twl6030_usb_probe(struct platform_device *pdev)
        if (status < 0) {
                dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
                        twl->irq2, status);
-               free_irq(twl->irq1, twl);
-               return status;
+               goto err_free_irq1;
        }
 
        twl->asleep = 0;
@@ -396,6 +395,13 @@ static int twl6030_usb_probe(struct platform_device *pdev)
        dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");
 
        return 0;
+
+err_free_irq1:
+       free_irq(twl->irq1, twl);
+err_put_regulator:
+       regulator_put(twl->usb3v3);
+
+       return status;
 }
 
 static int twl6030_usb_remove(struct platform_device *pdev)