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

dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset

The at_xdmac_memset_create_desc may return NULL, which will lead to a
null pointer dereference. For example, the len input is error, or the
atchan->free_descs_list is empty and memory is exhausted. Therefore, add
check to avoid this.

Fixes: b206d9a23ac7 ("dmaengine: xdmac: Add memset support")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Link: https://lore.kernel.org/r/20241029082845.1185380-1-chenridong@huaweicloud.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Chen Ridong and committed by
Vinod Koul
c43ec96e 40384c84

+2
+2
drivers/dma/at_xdmac.c
··· 1363 1363 return NULL; 1364 1364 1365 1365 desc = at_xdmac_memset_create_desc(chan, atchan, dest, len, value); 1366 + if (!desc) 1367 + return NULL; 1366 1368 list_add_tail(&desc->desc_node, &desc->descs_list); 1367 1369 1368 1370 desc->tx_dma_desc.cookie = -EBUSY;