All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init()
@ 2022-01-30 14:12 Christophe JAILLET
  2022-01-31 15:06 ` Sanjay R Mehta
  2022-02-02  7:15 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-01-30 14:12 UTC (permalink / raw)
  To: Sanjay R Mehta, Vinod Koul
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, dmaengine

In order to free resources correctly in the error handling path of
pt_core_init(), 2 goto's have to be switched. Otherwise, some resources
will leak and we will try to release things that have not been allocated
yet.

Fixes: fa5d823b16a9 ("dmaengine: ptdma: Initial driver for the AMD PTDMA")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/dma/ptdma/ptdma-dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ptdma/ptdma-dev.c b/drivers/dma/ptdma/ptdma-dev.c
index 8a6bf291a73f..3fa2a6ed4b68 100644
--- a/drivers/dma/ptdma/ptdma-dev.c
+++ b/drivers/dma/ptdma/ptdma-dev.c
@@ -207,7 +207,7 @@ int pt_core_init(struct pt_device *pt)
 	if (!cmd_q->qbase) {
 		dev_err(dev, "unable to allocate command queue\n");
 		ret = -ENOMEM;
-		goto e_dma_alloc;
+		goto e_pool;
 	}
 
 	cmd_q->qidx = 0;
@@ -230,7 +230,7 @@ int pt_core_init(struct pt_device *pt)
 	/* Request an irq */
 	ret = request_irq(pt->pt_irq, pt_core_irq_handler, 0, dev_name(pt->dev), pt);
 	if (ret)
-		goto e_pool;
+		goto e_dma_alloc;
 
 	/* Update the device registers with queue information. */
 	cmd_q->qcontrol &= ~CMD_Q_SIZE;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init()
  2022-01-30 14:12 [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init() Christophe JAILLET
@ 2022-01-31 15:06 ` Sanjay R Mehta
  2022-02-02  7:15 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Sanjay R Mehta @ 2022-01-31 15:06 UTC (permalink / raw)
  To: Christophe JAILLET, Sanjay R Mehta, Vinod Koul
  Cc: linux-kernel, kernel-janitors, dmaengine



On 1/30/2022 7:42 PM, Christophe JAILLET wrote:
> In order to free resources correctly in the error handling path of
> pt_core_init(), 2 goto's have to be switched. Otherwise, some resources
> will leak and we will try to release things that have not been allocated
> yet.
> 
> Fixes: fa5d823b16a9 ("dmaengine: ptdma: Initial driver for the AMD PTDMA")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Sanjay R Mehta <sanju.mehta@amd.com>
> ---
>  drivers/dma/ptdma/ptdma-dev.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/ptdma/ptdma-dev.c b/drivers/dma/ptdma/ptdma-dev.c
> index 8a6bf291a73f..3fa2a6ed4b68 100644
> --- a/drivers/dma/ptdma/ptdma-dev.c
> +++ b/drivers/dma/ptdma/ptdma-dev.c
> @@ -207,7 +207,7 @@ int pt_core_init(struct pt_device *pt)
>  	if (!cmd_q->qbase) {
>  		dev_err(dev, "unable to allocate command queue\n");
>  		ret = -ENOMEM;
> -		goto e_dma_alloc;
> +		goto e_pool;
>  	}
>  
>  	cmd_q->qidx = 0;
> @@ -230,7 +230,7 @@ int pt_core_init(struct pt_device *pt)
>  	/* Request an irq */
>  	ret = request_irq(pt->pt_irq, pt_core_irq_handler, 0, dev_name(pt->dev), pt);
>  	if (ret)
> -		goto e_pool;
> +		goto e_dma_alloc;
>  
>  	/* Update the device registers with queue information. */
>  	cmd_q->qcontrol &= ~CMD_Q_SIZE;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init()
  2022-01-30 14:12 [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init() Christophe JAILLET
  2022-01-31 15:06 ` Sanjay R Mehta
@ 2022-02-02  7:15 ` Dan Carpenter
  2022-02-02 18:45   ` Christophe JAILLET
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2022-02-02  7:15 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Sanjay R Mehta, Vinod Koul, linux-kernel, kernel-janitors, dmaengine

On Sun, Jan 30, 2022 at 03:12:09PM +0100, Christophe JAILLET wrote:
> @@ -230,7 +230,7 @@ int pt_core_init(struct pt_device *pt)
>  	/* Request an irq */
>  	ret = request_irq(pt->pt_irq, pt_core_irq_handler, 0, dev_name(pt->dev), pt);
>  	if (ret)
> -		goto e_pool;
> +		goto e_dma_alloc;

These are ComeFrom label names.  It's an unfortunate style of naming
labels based on the goto location instead of saying what the goto does.

This is one of those cases where the code has moved on, and now the name
no longer points to where it came from or to where it's going.  It just
stands as a Hyperart Thomasson pointing to the past.  It reminds us of
change and decay.  Take time to smell the air in autumn.  Beauty is all
around.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init()
  2022-02-02  7:15 ` Dan Carpenter
@ 2022-02-02 18:45   ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-02-02 18:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sanjay R Mehta, Vinod Koul, linux-kernel, kernel-janitors, dmaengine

Le 02/02/2022 à 08:15, Dan Carpenter a écrit :
> On Sun, Jan 30, 2022 at 03:12:09PM +0100, Christophe JAILLET wrote:
>> @@ -230,7 +230,7 @@ int pt_core_init(struct pt_device *pt)
>>   	/* Request an irq */
>>   	ret = request_irq(pt->pt_irq, pt_core_irq_handler, 0, dev_name(pt->dev), pt);
>>   	if (ret)
>> -		goto e_pool;
>> +		goto e_dma_alloc;
> 
> These are ComeFrom label names.  It's an unfortunate style of naming
> labels based on the goto location instead of saying what the goto does.
> 
> This is one of those cases where the code has moved on, and now the name
> no longer points to where it came from or to where it's going.  It just
> stands as a Hyperart Thomasson pointing to the past.  It reminds us of
> change and decay.  Take time to smell the air in autumn.  Beauty is all
> around.
> 
> regards,
> dan carpenter
> 

Autumn is over. Winter is coming (tm). And Spring will soon be there.

I'll try to send a refreshing update as a V2 to go one step further and 
do some spring cleaning in the labels used here.

CJ

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-02 18:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-30 14:12 [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init() Christophe JAILLET
2022-01-31 15:06 ` Sanjay R Mehta
2022-02-02  7:15 ` Dan Carpenter
2022-02-02 18:45   ` Christophe JAILLET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.