Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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

authored by

Thomas Fourier and committed by
Madhavan Srinivasan
760b9b4f cf183c17

+2 -4
+2 -4
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
··· 240 240 dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 241 241 242 242 /* Make DMA channel work with LPB FIFO data register */ 243 - if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) { 244 - ret = -EINVAL; 245 - goto err_dma_prep; 246 - } 243 + if (dma_dev->device_config(lpbfifo.chan, &dma_conf)) 244 + return -EINVAL; 247 245 248 246 sg_init_table(&sg, 1); 249 247