linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
@ 2025-06-05 16:37 Thomas Fourier
  2025-06-09  0:49 ` Michael Ellerman
  2025-06-09  7:40 ` Christophe Leroy
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Fourier @ 2025-06-05 16:37 UTC (permalink / raw)
  Cc: Thomas Fourier, Anatolij Gustschin, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Uwe Kleine-König,
	open list:LINUX FOR POWERPC EMBEDDED MPC5XXX, open list

If the device configuration fails (if `dma_dev->device_config()`),
`sg_dma_address(&sg)` is not initialized and the jump to `err_dma_prep`
leads to calling `dma_unmap_single()` on `sg_dma_address(&sg)`.

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 arch/powerpc/platforms/512x/mpc512x_lpbfifo.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
index 9668b052cd4b..ef3be438f914 100644
--- a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
+++ b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
@@ -241,8 +241,7 @@ static int mpc512x_lpbfifo_kick(void)
 
 	/* Make DMA channel work with LPB FIFO data register */
 	if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) {
-		ret = -EINVAL;
-		goto err_dma_prep;
+		return -EINVAL;
 	}
 
 	sg_init_table(&sg, 1);
-- 
2.43.0



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

* Re: [PATCH] (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
  2025-06-05 16:37 [PATCH] (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer Thomas Fourier
@ 2025-06-09  0:49 ` Michael Ellerman
  2025-06-09  7:40 ` Christophe Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2025-06-09  0:49 UTC (permalink / raw)
  To: Thomas Fourier
  Cc: Thomas Fourier, Anatolij Gustschin, Madhavan Srinivasan,
	Nicholas Piggin, Christophe Leroy, Uwe Kleine-König,
	open list:LINUX FOR POWERPC EMBEDDED MPC5XXX, open list

Thomas Fourier <fourier.thomas@gmail.com> writes:
> If the device configuration fails (if `dma_dev->device_config()`),
> `sg_dma_address(&sg)` is not initialized and the jump to `err_dma_prep`
> leads to calling `dma_unmap_single()` on `sg_dma_address(&sg)`.
>
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
>  arch/powerpc/platforms/512x/mpc512x_lpbfifo.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
> index 9668b052cd4b..ef3be438f914 100644
> --- a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
> +++ b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
> @@ -241,8 +241,7 @@ static int mpc512x_lpbfifo_kick(void)
>  
>  	/* Make DMA channel work with LPB FIFO data register */
>  	if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) {
> -		ret = -EINVAL;
> -		goto err_dma_prep;
> +		return -EINVAL;
>  	}
>  
>  	sg_init_table(&sg, 1);

Yep looks good. That's the first use of goto for error handling, and
it's clearly too early. All the previous error cases do a direct return.

Reviewed-by: Michael Ellerman <mpe@ellerman.id.au>

cheers


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

* Re: [PATCH] (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
  2025-06-05 16:37 [PATCH] (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer Thomas Fourier
  2025-06-09  0:49 ` Michael Ellerman
@ 2025-06-09  7:40 ` Christophe Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe Leroy @ 2025-06-09  7:40 UTC (permalink / raw)
  To: Thomas Fourier
  Cc: Anatolij Gustschin, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Uwe Kleine-König,
	open list:LINUX FOR POWERPC EMBEDDED MPC5XXX, open list



Le 05/06/2025 à 18:37, Thomas Fourier a écrit :
> [Vous ne recevez pas souvent de courriers de fourier.thomas@gmail.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> If the device configuration fails (if `dma_dev->device_config()`),
> `sg_dma_address(&sg)` is not initialized and the jump to `err_dma_prep`
> leads to calling `dma_unmap_single()` on `sg_dma_address(&sg)`.
> 
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
>   arch/powerpc/platforms/512x/mpc512x_lpbfifo.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
> index 9668b052cd4b..ef3be438f914 100644
> --- a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
> +++ b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
> @@ -241,8 +241,7 @@ static int mpc512x_lpbfifo_kick(void)
> 
>          /* Make DMA channel work with LPB FIFO data register */
>          if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) {
> -               ret = -EINVAL;
> -               goto err_dma_prep;
> +               return -EINVAL;
>          }

You should remove the { } as it is now a single line.

> 
>          sg_init_table(&sg, 1);
> --
> 2.43.0
> 



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

end of thread, other threads:[~2025-06-09  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05 16:37 [PATCH] (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer Thomas Fourier
2025-06-09  0:49 ` Michael Ellerman
2025-06-09  7:40 ` Christophe Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).