Linux-CIFS Archive mirror
 help / color / mirror / Atom feed
From: Henrique Carvalho <henrique.carvalho@suse.com>
To: sfrench@samba.org
Cc: metze@samba.org, pc@manguebit.org, ronniesahlberg@gmail.com,
	sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com,
	ematsumiya@suse.de, linux-cifs@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH 3/3] smb: client: make smb3_update_ses_channels() match expected API
Date: Wed, 29 Apr 2026 17:52:36 -0300	[thread overview]
Message-ID: <20260429205236.456099-3-henrique.carvalho@suse.com> (raw)
In-Reply-To: <20260429205236.456099-1-henrique.carvalho@suse.com>

smb3_update_ses_channels() was introduced with a 0-or-errno API, but
could return a positive channel count when growing channels. Existing
reconnect paths mostly tolerated this, but newer callers can treat it as
failure.

Normalize positive return values from cifs_try_adding_channels() to 0 so
smb3_update_ses_channels() follows the expected API used by its callers.

Fixes: ef529f655a2c ("cifs: client: allow changing multichannel mount options on remount")
Cc: stable@vger.kernel.org
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
---
 fs/smb/client/smb2pdu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index cb61051f9af3..9eb7c16407cc 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -236,9 +236,11 @@ int smb3_update_ses_channels(struct cifs_ses *ses, struct TCP_Server_Info *serve
 	if (disable_mchan)
 		rc = cifs_chan_skip_or_disable(ses, server, from_reconnect, disable_mchan);
 	else {
-		if (ses->chan_count < ses->chan_max)
+		if (ses->chan_count < ses->chan_max) {
 			rc = cifs_try_adding_channels(ses);
-		else if (ses->chan_count > ses->chan_max)
+			if (rc > 0)
+				rc = 0;
+		} else if (ses->chan_count > ses->chan_max)
 			rc = cifs_chan_skip_or_disable(ses, server, from_reconnect, disable_mchan);
 	}
 
-- 
2.53.0


      parent reply	other threads:[~2026-04-29 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 20:52 [PATCH 1/3] smb: client: fix conflicting option validation for new mount API Henrique Carvalho
2026-04-29 20:52 ` [PATCH 2/3] smb: client: fix race in multichannel rescaling during mount Henrique Carvalho
2026-04-29 20:52 ` Henrique Carvalho [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429205236.456099-3-henrique.carvalho@suse.com \
    --to=henrique.carvalho@suse.com \
    --cc=bharathsm@microsoft.com \
    --cc=ematsumiya@suse.de \
    --cc=linux-cifs@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=sfrench@samba.org \
    --cc=sprasad@microsoft.com \
    --cc=stable@vger.kernel.org \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).