Skip to content

Commit c352237

Browse files
Xu Yilungregkh
authored andcommitted
fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable()
commit 1ca6106 upstream. dma_map_sgtable() returns only 0 or the error code. Read sgt->nents to get the number of mapped segments. Fixes: 37e0070 ("zynq_fpga: use sgtable-based scatterlist wrappers") Reported-by: Pavel Pisa <pisa@fel.cvut.cz> Closes: https://lore.kernel.org/linux-fpga/202508041548.22955.pisa@fel.cvut.cz/ Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com> Tested-by: Pavel Pisa <pisa@fel.cvut.cz> Link: https://lore.kernel.org/r/20250806070605.1920909-2-yilun.xu@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 944e732 commit c352237

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/fpga/zynq-fpga.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,12 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt)
405405
}
406406
}
407407

408-
priv->dma_nelms =
409-
dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0);
410-
if (priv->dma_nelms == 0) {
408+
err = dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0);
409+
if (err) {
411410
dev_err(&mgr->dev, "Unable to DMA map (TO_DEVICE)\n");
412-
return -ENOMEM;
411+
return err;
413412
}
413+
priv->dma_nelms = sgt->nents;
414414

415415
/* enable clock */
416416
err = clk_enable(priv->clk);

0 commit comments

Comments
 (0)