From nobody Sun Feb 8 14:52:06 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98183396F4 for ; Fri, 9 Jan 2026 10:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767955171; cv=none; b=h2ep5azZqcoj5WQP0WXRMDnKONg0gCWjD4jqHP0wJoKZ2EVRarARAHypDpRG/4AXbSfHhUYG4EaN+6nSFUeaixhwOqAxPzV0wCf+U2lRh6ltAqQPe4huTpjVsvjMEMe8pKQm/OTMPVo5rw4hyOSvHw/GdNzjw1lzWXRmx2TMw0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767955171; c=relaxed/simple; bh=zAbQnwKQSgBP6p7KWlWw9DcpzSJFpicgY3jt9qQvxcc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PyJoT7sFfkyw7g34YWuub8dGQlHwsFWDdQjnAgfODUHqe4Rx0T+A/ocDYt21mVBnpaeV96wJB2LadABcYH5iKKDcZlzjWo+zM/E3P4DjGuCjOxoj1MBWm79IDDQIDuxsEeWy5mDTlqHu5cfbfKsGpjK+5CqNrxkweOnM0Ks/Jl0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lh8RBW7B; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lh8RBW7B" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4779d8286d8so4385695e9.0 for ; Fri, 09 Jan 2026 02:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767955168; x=1768559968; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Rnq5gnjYEBiVhXaKRyzgwQ5WDJS4cAZPYtKFe/+ivNc=; b=lh8RBW7BYD++KMfj+WNAxkINQ3RgUvUQjlv3Ufo9JX7niyBShY5b4ABflVL1aPZVNa /SO101e39p9GLdwKB9bdPphgnRtj7/M3gDRt6T9zFLjULIqFfal5pJy3L7FLA1X8hehg wFlhQNxqpiHjbbb4EEmvVzvnL+Yg0fmZwXlqvbJ7eztZUUGEXfQoe3pWfp1+Nkbmpl/9 C6XnmNerQvPpHBMMEZbc3K1Ex1bYpOi/TgQ0q3rS+QumrMcWOtB2fxHjgiZ7YZHY+K2h aax+be4/HSwjSct8OoJ1G0dp6fvlJiNRUHp58EEkSXtvfpYi28VWzKneRGrOgSXA6bTq pPDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767955168; x=1768559968; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Rnq5gnjYEBiVhXaKRyzgwQ5WDJS4cAZPYtKFe/+ivNc=; b=s/Y0ok2mkcWQY512UImo126hbjk7shXjCPk36IdyvWnpqN6A0xejJt18ziD5dpPAMt h+CLD/SXAU9hwSCuwc8qi1Ze5dneVdSL82Z8lGTG+UZgLtuWSTIQjZp/eWDRdHqvltFt 9hCT/6iiBY8pxqrWg1yYpRRiP1G2/s+IVx3w5QYS+7GU4OMiFcB2gnbkfptsqWlYvvZx amsuu0zOFOBJ/Pz4gCuuGaR17pEJajok3II2suSWNxPNpfAd4McAYvlStvAHz9cs1KRd WKMviBZ7ogWT0AFXqnXl8cSRD/2UFC1UHMZvo5cgd9kEGWuIgFvH5l/EaoOJ9IsO6CS8 /bYA== X-Forwarded-Encrypted: i=1; AJvYcCWJLD6xS+QM87b4c3aefgjSHtt9ZM82jUWhDT5ff9FA+K9qbeji58GD/lV0lFdDHLxNaYt3If+sXUkipbA=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6K6plFn15JIuD8cz7g7VL+ZOK5P1F7AzRSvIq3tkEbZOkkoO9 MoVcW+pkEfmRiPz8NgKmfJops9qytBAYXmlPYsw8W+K+bDq9vznxBH0d X-Gm-Gg: AY/fxX6dBx7JGEql61zfPaN9gdKEwxBXL1ZXkq4FiNve9ns/JcP7ZAMDdO9A7L5kYdC 08v7kj8x1SnH+dy8f+pj6Y2JMJGBcXiUC3q7p972kl2h6do1mLQrSH0ZcqqRf0G0NUGgyxXGIoq wf0qaLk3WYTmLsGp63YEp4Wkyv/x/cNYfSv/5y96u5pCwwLPLqRB9KezRuVH4zORx5pIMey88eU dzFdLXdruiPE3sQqquve4ijTDbHLtfI+UQwrF9Wu7tFNQtW1nh3H8FVOYORl4zfnROzrmR3a+df d1x8bdCUF9i3nBgdqbPdbbL265LIqiHQtbGArz1qeTVedxYFe52Wa+thjNg1sZ7QlqIGpiGIbWG iubO+p0IepS8FPqUrGT8xKBa3K1NPnzfNFsK7Rq9LwnOX7S+qjUXmeAnI06dPgZfga8KhxojWYf A+b8knPoT7sPr+YQAhe+9xMZDCYvgfrJ59E7L7xyIixPjR3Q8EBtQINbDWbQW8NPDjFXligheWx sxGu1U= X-Google-Smtp-Source: AGHT+IHciyXHKUeAGcmyGH9e9/cNeiCCj6AtY6qRKQqbQ6xmqXicuHAMta4fNJAQ21qLP44qM8jCkA== X-Received: by 2002:a05:600c:3556:b0:477:9fd6:7a53 with SMTP id 5b1f17b1804b1-47d84b04e1amr63078895e9.2.1767955167881; Fri, 09 Jan 2026 02:39:27 -0800 (PST) Received: from thomas-precision3591.paris.inria.fr (wifi-pro-83-215.paris.inria.fr. [128.93.83.215]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-432bd5edd51sm21697194f8f.29.2026.01.09.02.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 02:39:27 -0800 (PST) From: Thomas Fourier To: Cc: Thomas Fourier , stable@vger.kernel.org, Namjae Jeon , Steve French , Sergey Senozhatsky , Tom Talpey , Hyunchul Lee , Ronnie Sahlberg , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ksmbd: smbd: fix dma_unmap_sg() nents Date: Fri, 9 Jan 2026 11:38:39 +0100 Message-ID: <20260109103840.55252-2-fourier.thomas@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned. Fixes: 0626e6641f6b ("cifsd: add server handler for central processing and = tranport layers") Cc: Signed-off-by: Thomas Fourier --- fs/smb/server/transport_rdma.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c index f585359684d4..8620690aa2ec 100644 --- a/fs/smb/server/transport_rdma.c +++ b/fs/smb/server/transport_rdma.c @@ -1353,14 +1353,12 @@ static int get_sg_list(void *buf, int size, struct = scatterlist *sg_list, int nen =20 static int get_mapped_sg_list(struct ib_device *device, void *buf, int siz= e, struct scatterlist *sg_list, int nentries, - enum dma_data_direction dir) + enum dma_data_direction dir, int *npages) { - int npages; - - npages =3D get_sg_list(buf, size, sg_list, nentries); - if (npages < 0) + *npages =3D get_sg_list(buf, size, sg_list, nentries); + if (*npages < 0) return -EINVAL; - return ib_dma_map_sg(device, sg_list, npages, dir); + return ib_dma_map_sg(device, sg_list, *npages, dir); } =20 static int post_sendmsg(struct smbdirect_socket *sc, @@ -1431,12 +1429,13 @@ static int smb_direct_post_send_data(struct smbdire= ct_socket *sc, for (i =3D 0; i < niov; i++) { struct ib_sge *sge; int sg_cnt; + int npages; =20 sg_init_table(sg, SMBDIRECT_SEND_IO_MAX_SGE - 1); sg_cnt =3D get_mapped_sg_list(sc->ib.dev, iov[i].iov_base, iov[i].iov_len, sg, SMBDIRECT_SEND_IO_MAX_SGE - 1, - DMA_TO_DEVICE); + DMA_TO_DEVICE, &npages); if (sg_cnt <=3D 0) { pr_err("failed to map buffer\n"); ret =3D -ENOMEM; @@ -1444,7 +1443,7 @@ static int smb_direct_post_send_data(struct smbdirect= _socket *sc, } else if (sg_cnt + msg->num_sge > SMBDIRECT_SEND_IO_MAX_SGE) { pr_err("buffer not fitted into sges\n"); ret =3D -E2BIG; - ib_dma_unmap_sg(sc->ib.dev, sg, sg_cnt, + ib_dma_unmap_sg(sc->ib.dev, sg, npages, DMA_TO_DEVICE); goto err; } --=20 2.43.0