diff mbox series

dmaengine: ti: k3-udma: Fix a resource leak in an error handling path

Message ID 20210124070923.724479-1-christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Headers show
Series dmaengine: ti: k3-udma: Fix a resource leak in an error handling path | expand

Commit Message

Christophe JAILLET Jan. 24, 2021, 7:09 a.m. UTC
In 'dma_pool_create()', we return -ENOMEM, but don't release the resources
already allocated, as in all the other error handling paths.

Go to 'err_res_free' instead of returning directly.

Fixes: 017794739702 ("dmaengine: ti: k3-udma: Initial support for K3 BCDMA")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is not even compile tested.
I don't have the needed configuration.
---
 drivers/dma/ti/k3-udma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Péter Ujfalusi Jan. 25, 2021, 11:13 a.m. UTC | #1
Hi,

On 1/24/21 9:09 AM, Christophe JAILLET wrote:
> In 'dma_pool_create()', we return -ENOMEM, but don't release the resources
> already allocated, as in all the other error handling paths.
> 
> Go to 'err_res_free' instead of returning directly.

Interesting that I only had error for the bcdma path...

> Fixes: 017794739702 ("dmaengine: ti: k3-udma: Initial support for K3 BCDMA")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is not even compile tested.
> I don't have the needed configuration.

No issue, that patch is trivial,

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> ---
>   drivers/dma/ti/k3-udma.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 8e3fd1119a77..96ad21869ba7 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -2447,7 +2447,8 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
>   			dev_err(ud->ddev.dev,
>   				"Descriptor pool allocation failed\n");
>   			uc->use_dma_pool = false;
> -			return -ENOMEM;
> +			ret = -ENOMEM;
> +			goto err_res_free;
>   		}
>   
>   		uc->use_dma_pool = true;
>
Vinod Koul Jan. 26, 2021, 5:32 p.m. UTC | #2
On 24-01-21, 08:09, Christophe JAILLET wrote:
> In 'dma_pool_create()', we return -ENOMEM, but don't release the resources
> already allocated, as in all the other error handling paths.
> 
> Go to 'err_res_free' instead of returning directly.

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 8e3fd1119a77..96ad21869ba7 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -2447,7 +2447,8 @@  static int bcdma_alloc_chan_resources(struct dma_chan *chan)
 			dev_err(ud->ddev.dev,
 				"Descriptor pool allocation failed\n");
 			uc->use_dma_pool = false;
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto err_res_free;
 		}
 
 		uc->use_dma_pool = true;