[PATCH v1 08/11] media: intel/ipu6: return an error from ipu6_dma_map_sgtable() on failure

From: Valerii Sokolov

Date: Fri Oct 23 2026 - 16:05:19 EST


ipu6_dma_map_sg() returns 0 when ipu6_mmu_map() fails, but
ipu6_dma_map_sgtable() only treats negative values as errors. On failure
it therefore sets sgt->nents to 0 and returns success, and callers such
as ipu6_isys_buf_init() and ipu6_map_fw_region() go on to hand the
hardware an address that is not mapped in the IPU MMU.

Return -ENOMEM when ipu6_dma_map_sg() maps no entries.

Fixes: daabc5c64703 ("media: ipu6: not override the dma_ops of device in driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Valerii Sokolov <valerii.sokolov@xxxxx>
---
drivers/media/pci/intel/ipu6/ipu6-dma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-dma.c b/drivers/media/pci/intel/ipu6/ipu6-dma.c
index a923a1e4bd..37b5c25259 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-dma.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-dma.c
@@ -459,8 +459,8 @@ int ipu6_dma_map_sgtable(struct ipu6_bus_device *sys, struct sg_table *sgt,
int nents;

nents = ipu6_dma_map_sg(sys, sgt->sgl, sgt->nents, dir, attrs);
- if (nents < 0)
- return nents;
+ if (nents <= 0)
+ return nents < 0 ? nents : -ENOMEM;

sgt->nents = nents;

--
2.56.0