From: Markus Elfring <Markus.Elfring@web.de>
To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
Bharath SM <bharathsm@microsoft.com>,
Paulo Alcantara <pc@manguebit.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Steve French <sfrench@samba.org>, Tom Talpey <tom@talpey.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] smb: client: Use more common code in SMB2_tcon()
Date: Thu, 9 Oct 2025 10:44:12 +0200 [thread overview]
Message-ID: <e06df807-e264-48ed-9f7b-0cfaefb296e7@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 9 Oct 2025 10:37:39 +0200
Use an additional label so that a bit of common code can be better reused
at the end of this function implementation.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/smb/client/smb2pdu.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 42e2d4ea344d..fce755fb2b80 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -2056,8 +2056,8 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
unc_path_len = cifs_strtoUTF16(unc_path, tree, strlen(tree), cp);
if (unc_path_len <= 0) {
- kfree(unc_path);
- return -EINVAL;
+ rc = -EINVAL;
+ goto free_unc_path;
}
unc_path_len *= 2;
@@ -2066,10 +2066,8 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
atomic_set(&tcon->num_remote_opens, 0);
rc = smb2_plain_req_init(SMB2_TREE_CONNECT, tcon, server,
(void **) &req, &total_len);
- if (rc) {
- kfree(unc_path);
- return rc;
- }
+ if (rc)
+ goto free_unc_path;
if (smb3_encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ;
@@ -2160,6 +2158,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
tcon_exit:
free_rsp_buf(resp_buftype, rsp);
+free_unc_path:
kfree(unc_path);
return rc;
--
2.51.0
reply other threads:[~2025-10-09 8:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=e06df807-e264-48ed-9f7b-0cfaefb296e7@web.de \
--to=markus.elfring@web.de \
--cc=bharathsm@microsoft.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--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).