]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
accel/amdxdna: Return ERR_PTR on dma_alloc_noncoherent failure
authorWendy Liang <wendy.liang@amd.com>
Mon, 23 Mar 2026 17:37:19 +0000 (10:37 -0700)
committerLizhi Hou <lizhi.hou@amd.com>
Mon, 23 Mar 2026 20:29:22 +0000 (13:29 -0700)
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 <wendy.liang@amd.com>
Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20260323173719.2311474-1-lizhi.hou@amd.com
drivers/accel/amdxdna/aie2_message.c

index 7e219a5eda56b8f8f5486c56fc48c9f2a55e2f19..a1c546c3e81c340f29af1dfecbb4911420051f4d 100644 (file)
@@ -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,