From: Chen Ridong Date: Tue, 29 Oct 2024 08:28:45 +0000 (+0000) Subject: dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset X-Git-Tag: v5.10.233~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed1a8aaa344522c0c349ac9042db27ad130ef913;p=thirdparty%2Fkernel%2Fstable.git dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset commit c43ec96e8d34399bd9dab2f2dc316b904892133f upstream. 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 Link: https://lore.kernel.org/r/20241029082845.1185380-1-chenridong@huaweicloud.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 861be862a775a..8a7c98f093ce1 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1220,6 +1220,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;