diff mbox series

crypto: ccp - Fix a resource leak in an error handling path

Message ID 4af832b7e75b729ebfb0f07fe039dc47712512c2.1621146079.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: ccp - Fix a resource leak in an error handling path | expand

Commit Message

Christophe JAILLET May 16, 2021, 6:58 a.m. UTC
If an error occurs after calling 'sp_get_irqs()', 'sp_free_irqs()' must be
called as already done in the error handling path.

Fixes: f4d18d656f88 ("crypto: ccp - Abstract interrupt registeration")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/crypto/ccp/sp-pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

John Allen May 19, 2021, 8:56 p.m. UTC | #1
On Sun, May 16, 2021 at 08:58:04AM +0200, Christophe JAILLET wrote:
> If an error occurs after calling 'sp_get_irqs()', 'sp_free_irqs()' must be
> called as already done in the error handling path.
> 
> Fixes: f4d18d656f88 ("crypto: ccp - Abstract interrupt registeration")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: John Allen <john.allen@amd.com>

> ---
>  drivers/crypto/ccp/sp-pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
> index f468594ef8af..6fb6ba35f89d 100644
> --- a/drivers/crypto/ccp/sp-pci.c
> +++ b/drivers/crypto/ccp/sp-pci.c
> @@ -222,7 +222,7 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  		if (ret) {
>  			dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n",
>  				ret);
> -			goto e_err;
> +			goto free_irqs;
>  		}
>  	}
>  
> @@ -230,10 +230,12 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  
>  	ret = sp_init(sp);
>  	if (ret)
> -		goto e_err;
> +		goto free_irqs;
>  
>  	return 0;
>  
> +free_irqs:
> +	sp_free_irqs(sp);
>  e_err:
>  	dev_notice(dev, "initialization failed\n");
>  	return ret;
> -- 
> 2.30.2
>
Herbert Xu May 21, 2021, 8:23 a.m. UTC | #2
On Sun, May 16, 2021 at 08:58:04AM +0200, Christophe JAILLET wrote:
> If an error occurs after calling 'sp_get_irqs()', 'sp_free_irqs()' must be
> called as already done in the error handling path.
> 
> Fixes: f4d18d656f88 ("crypto: ccp - Abstract interrupt registeration")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/crypto/ccp/sp-pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
index f468594ef8af..6fb6ba35f89d 100644
--- a/drivers/crypto/ccp/sp-pci.c
+++ b/drivers/crypto/ccp/sp-pci.c
@@ -222,7 +222,7 @@  static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		if (ret) {
 			dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n",
 				ret);
-			goto e_err;
+			goto free_irqs;
 		}
 	}
 
@@ -230,10 +230,12 @@  static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	ret = sp_init(sp);
 	if (ret)
-		goto e_err;
+		goto free_irqs;
 
 	return 0;
 
+free_irqs:
+	sp_free_irqs(sp);
 e_err:
 	dev_notice(dev, "initialization failed\n");
 	return ret;