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

serial: amba-pl011: prefer dma_mapping_error() over explicit address checking

Check for returned DMA addresses using specialized dma_mapping_error()
helper which is generally recommended for this purpose by
Documentation/core-api/dma-api.rst:

"In some circumstances dma_map_single(), ...
will fail to create a mapping. A driver can check for these errors
by testing the returned DMA address with dma_mapping_error()."

Found via static analysis and this is similar to commit fa0308134d26
("ALSA: memalloc: prefer dma_mapping_error() over explicit address checking")

Fixes: 58ac1b379979 ("ARM: PL011: Fix DMA support")
Cc: stable <stable@kernel.org>
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Link: https://patch.msgid.link/20251027092053.87937-1-linmq006@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Miaoqian Lin and committed by
Greg Kroah-Hartman
eb4917f5 dcb6fa37

+1 -1
+1 -1
drivers/tty/serial/amba-pl011.c
··· 628 628 dmatx->len = count; 629 629 dmatx->dma = dma_map_single(dma_dev->dev, dmatx->buf, count, 630 630 DMA_TO_DEVICE); 631 - if (dmatx->dma == DMA_MAPPING_ERROR) { 631 + if (dma_mapping_error(dma_dev->dev, dmatx->dma)) { 632 632 uap->dmatx.queued = false; 633 633 dev_dbg(uap->port.dev, "unable to map TX DMA\n"); 634 634 return -EBUSY;