Commit c43ec96e authored by Chen Ridong's avatar Chen Ridong Committed by Vinod Koul
Browse files

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: b206d9a2 ("dmaengine: xdmac: Add memset support")
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
Link: https://lore.kernel.org/r/20241029082845.1185380-1-chenridong@huaweicloud.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 40384c84
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1363,6 +1363,8 @@ at_xdmac_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
		return NULL;

	desc = at_xdmac_memset_create_desc(chan, atchan, dest, len, value);
	if (!desc)
		return NULL;
	list_add_tail(&desc->desc_node, &desc->descs_list);

	desc->tx_dma_desc.cookie = -EBUSY;