]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset
authorChen Ridong <chenridong@huawei.com>
Tue, 29 Oct 2024 08:28:45 +0000 (08:28 +0000)
committerVinod Koul <vkoul@kernel.org>
Mon, 2 Dec 2024 16:44:19 +0000 (22:14 +0530)
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>
drivers/dma/at_xdmac.c

index 9c7b402200040f6e781172389b41587e076fff68..ba25c23164e7898e0d7684a4b70d2ded4d3445c8 100644 (file)
@@ -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;