Skip to contentSkip to conversation

(powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer

PATCH In review Thomas Fourier 2 participants 2 messages Jun 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer

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).

---
 arch/powerpc/platforms/512x/mpc512x_lpbfifo.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c +2 -4
index 9668b052cd4b..f251e0f68262 100644
@@ -240,10 +240,8 @@ static int mpc512x_lpbfifo_kick(void)
 	dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 
 	/* Make DMA channel work with LPB FIFO data register */
-	if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) {
-		ret = -EINVAL;
-		goto err_dma_prep;
-	}
+	if (dma_dev->device_config(lpbfifo.chan, &dma_conf))
+		return -EINVAL;
 
 	sg_init_table(&sg, 1);
 
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw

Le 10/06/2025 à 16:29, Thomas Fourier a écrit :

Quoted 7 lines

[Vous ne recevez pas souvent de courriers de [email protected]. 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).

Quoted 24 lines
---
  arch/powerpc/platforms/512x/mpc512x_lpbfifo.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c +2 -5
index 9668b052cd4b..f251e0f68262 100644
@@ -240,10 +240,8 @@ static int mpc512x_lpbfifo_kick(void)
         dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
 
         /* Make DMA channel work with LPB FIFO data register */
-       if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) {
-               ret = -EINVAL;
-               goto err_dma_prep;
-       }
+       if (dma_dev->device_config(lpbfifo.chan, &dma_conf))
+               return -EINVAL;
 
         sg_init_table(&sg, 1);
 
--

2.43.0