dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset

ANBZ: #21324

commit c43ec96e8d 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: b206d9a23a ("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>
Fixes: CVE-2024-56767
Signed-off-by: Wang Yaxin <wang.yaxin@zte.com.cn>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/5331
This commit is contained in:
Chen Ridong 2024-10-29 08:28:45 +00:00 committed by 小龙
parent 0f9a0fe042
commit d20f0c84a1
1 changed files with 2 additions and 0 deletions

View File

@ -1213,6 +1213,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;