commit 1ca61060de92a4320d73adfe5dc8d335653907ac upstream. dma_map_sgtable() returns only 0 or the error code. Read sgt->nents to get the number of mapped segments. Fixes: 37e00703228a ("zynq_fpga: use sgtable-based scatterlist wrappers") Reported-by: Pavel Pisa <[email protected]> Closes: https://lore.kernel.org/linux-fpga/[email protected]/ Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Marek Szyprowski <[email protected]> Signed-off-by: Xu Yilun <[email protected]> Tested-by: Pavel Pisa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>