[PATCH] smb: client: Avoid redundant statements after a failed kmalloc() in SMB2_sess_auth_rawntlmssp_negotiate()

Markus Elfring posted 1 patch 2 months, 1 week ago
fs/smb/client/smb2pdu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] smb: client: Avoid redundant statements after a failed kmalloc() in SMB2_sess_auth_rawntlmssp_negotiate()
Posted by Markus Elfring 2 months, 1 week ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 9 Oct 2025 10:55:16 +0200

Use an additional label so that statements (which are not useful after
a failed kmalloc() call) can be skipped in this function implementation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/smb/client/smb2pdu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 42e2d4ea344d..ff83d672aa05 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -1724,7 +1724,7 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data)
 	ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL);
 	if (!ses->ntlmssp) {
 		rc = -ENOMEM;
-		goto out_err;
+		goto out_set_result;
 	}
 	ses->ntlmssp->sesskey_per_smbsess = true;
 
@@ -1793,6 +1793,7 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data)
 out_err:
 	kfree_sensitive(ses->ntlmssp);
 	ses->ntlmssp = NULL;
+out_set_result:
 	sess_data->result = rc;
 	sess_data->func = NULL;
 }
-- 
2.51.0