From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C9D02F7473; Tue, 26 Aug 2025 13:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756215157; cv=none; b=oYd28ZyTOsh1bblLlGfQv8PVGByiVz1mC1aueX8IEvDN6wxtYEX1H00ORt2QudRfYMeYZVQ3IZcnC1kjHSJRh7If9PhifWsjXR8AN20+EWtQUd+KJlUEMIaTn02ddB20ouE6MNFLLQpTbUQ0Pk00pYgEpzLLn110P+UbQy/NVlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756215157; c=relaxed/simple; bh=TnqQmVkn7CcpmjuyFSWA9ybJFujwdUMXERQbb3v4do8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LfIfIMBBVXJ//A7t/X9axbAa+dYSidycr+EkhMO7Eur7Vw+KQinKYozPzE8crrKyLy6RLwichqLPoEYqEUtsRBfZUymWliDtcdVkWRvLodFG1A5LjyZRgrs37UAX9J8pB+3+sxdAmxNeGYsW76VI7+tAUAtbbSQwULUmDUY8gtA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OLdwlX1m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OLdwlX1m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C18BBC4CEF1; Tue, 26 Aug 2025 13:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756215157; bh=TnqQmVkn7CcpmjuyFSWA9ybJFujwdUMXERQbb3v4do8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLdwlX1m7SvzdrY8fUgXdv4DAlehCW9vGV5pthO4ijoW8iaFRJeuGgS4CRfD46/dx CkGqIUZWGA9wDvw0MgylCc/zP7kIGFn8ObIfhVeoCfB6AZ+DUiN/Flyuy3YC5/n7FG gyFd2lqfC3OnSk3yG5UtYLff8Wp3PhBzvotQDaq0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pavel Pisa , Jason Gunthorpe , Marek Szyprowski , Xu Yilun Subject: [PATCH 6.1 408/482] fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable() Date: Tue, 26 Aug 2025 13:11:01 +0200 Message-ID: <20250826110940.909051327@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110930.769259449@linuxfoundation.org> References: <20250826110930.769259449@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xu Yilun 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 Closes: https://lore.kernel.org/linux-fpga/202508041548.22955.pisa@fel.cvut.cz/ Reviewed-by: Jason Gunthorpe Reviewed-by: Marek Szyprowski Signed-off-by: Xu Yilun Tested-by: Pavel Pisa Link: https://lore.kernel.org/r/20250806070605.1920909-2-yilun.xu@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/fpga/zynq-fpga.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/fpga/zynq-fpga.c +++ b/drivers/fpga/zynq-fpga.c @@ -405,12 +405,12 @@ static int zynq_fpga_ops_write(struct fp } } - priv->dma_nelms = - dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0); - if (priv->dma_nelms == 0) { + err = dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0); + if (err) { dev_err(&mgr->dev, "Unable to DMA map (TO_DEVICE)\n"); - return -ENOMEM; + return err; } + priv->dma_nelms = sgt->nents; /* enable clock */ err = clk_enable(priv->clk);