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 7AF70362084; Tue, 26 Aug 2025 14:41:06 +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=1756219266; cv=none; b=rtlHtE5NuMiLiaZTYZrd7/zj2cIL63vwHsh2rDR9isUXa+mXEaVVtcn0AzG9Fw/CVcEUWBJVvkurqHmS8Brl6TgRd1nEuB2yvsqddqZls3QOsxoQe++HlfpoEEwJBmLzITQ86Gd8Zyh1KfUC8ywiVZxVRRltiPHaW1PHQraKwPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219266; c=relaxed/simple; bh=6LmisT4qe/heEaj9YA0blcGVtv0oc0GRRIjh6+NNHH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S0lmsEFsfs0VcUL4VDTtFK12CQWyfFpovbmgjN7ZgRq8FTYXlSb9LZJvuGeH8Lgi8pU/YLPZIZKzkhsGwQm598h+x9ipR224bHNT5NGlUtMlT3rfdVyjg49PTXKLQptCqQYMQfkW7hEIiPfqMzopDdoe1UWpLAHUXtzq2q9tXEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZwIVxbO4; 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="ZwIVxbO4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BDACC116B1; Tue, 26 Aug 2025 14:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756219266; bh=6LmisT4qe/heEaj9YA0blcGVtv0oc0GRRIjh6+NNHH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZwIVxbO4HqdvJNK0KG14RqsIf94Az0S6Q308vxtqBOuQbgf7K0cYzvl+1ud7Ed9X+ WT2g3RvpKud6kioHN+cXEgQxTeVK6h2XqiaGpJFoAp+P/lVtfNzTPSwBrIrb8MZWPQ 52v9l3WQ++UrabFQaa1b9f5evboW1Iuqo58puSq4= 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 5.4 315/403] fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable() Date: Tue, 26 Aug 2025 13:10:41 +0200 Message-ID: <20250826110915.519496664@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110905.607690791@linuxfoundation.org> References: <20250826110905.607690791@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 5.4-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);