]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
(powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
authorThomas Fourier <fourier.thomas@gmail.com>
Tue, 10 Jun 2025 14:29:11 +0000 (16:29 +0200)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Wed, 9 Jul 2025 03:45:10 +0000 (09:15 +0530)
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>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250610142918.169540-2-fourier.thomas@gmail.com
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c

index 9668b052cd4b3a6bbd2a37b1993e569964e822a1..f251e0f6826204c0c0733b61ab6f3594b3380d92 100644 (file)
@@ -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);