From: Wendy Liang Date: Mon, 23 Mar 2026 17:37:19 +0000 (-0700) Subject: accel/amdxdna: Return ERR_PTR on dma_alloc_noncoherent failure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=140cfee588af8656822b835ccd28515f0b8c77cf;p=thirdparty%2Fkernel%2Fstable.git accel/amdxdna: Return ERR_PTR on dma_alloc_noncoherent failure dma_alloc_noncoherent() returns NULL on failure, but callers of aie2_alloc_msg_buffer() check for IS_ERR(). Return ERR_PTR(-ENOMEM) instead of NULL to match the amdxdna_iommu_alloc() path and the caller's error checking convention. Fixes: ece3e8980907 ("accel/amdxdna: Allow forcing IOVA-based DMA via module parameter") Signed-off-by: Wendy Liang Reviewed-by: Karol Wachowski Reviewed-by: Mario Limonciello (AMD) Signed-off-by: Lizhi Hou Link: https://patch.msgid.link/20260323173719.2311474-1-lizhi.hou@amd.com --- diff --git a/drivers/accel/amdxdna/aie2_message.c b/drivers/accel/amdxdna/aie2_message.c index 7e219a5eda56..a1c546c3e81c 100644 --- a/drivers/accel/amdxdna/aie2_message.c +++ b/drivers/accel/amdxdna/aie2_message.c @@ -56,6 +56,7 @@ void *aie2_alloc_msg_buffer(struct amdxdna_dev_hdl *ndev, u32 *size, dma_addr_t *dma_addr) { struct amdxdna_dev *xdna = ndev->xdna; + void *vaddr; int order; *size = max(*size, SZ_8K); @@ -67,8 +68,12 @@ void *aie2_alloc_msg_buffer(struct amdxdna_dev_hdl *ndev, u32 *size, if (amdxdna_iova_on(xdna)) return amdxdna_iommu_alloc(xdna, *size, dma_addr); - return dma_alloc_noncoherent(xdna->ddev.dev, *size, dma_addr, + vaddr = dma_alloc_noncoherent(xdna->ddev.dev, *size, dma_addr, DMA_FROM_DEVICE, GFP_KERNEL); + if (!vaddr) + return ERR_PTR(-ENOMEM); + + return vaddr; } void aie2_free_msg_buffer(struct amdxdna_dev_hdl *ndev, size_t size,