]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: client: Use more common error handling code in smb3_reconfigure()
authorMarkus Elfring <elfring@users.sourceforge.net>
Thu, 11 Jun 2026 15:33:39 +0000 (17:33 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 14 Jun 2026 20:12:24 +0000 (15:12 -0500)
Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/fs_context.c

index fd4b13cd654d90e7d3fc19af16ca14ce83860c95..9addc74ce57e8bf97de1d057760c9593c41c553b 100644 (file)
@@ -1092,10 +1092,8 @@ static int smb3_reconfigure(struct fs_context *fc)
                return -ENOMEM;
 
        rc = smb3_fs_context_dup(old_ctx, cifs_sb->ctx);
-       if (rc) {
-               kfree(old_ctx);
-               return rc;
-       }
+       if (rc)
+               goto free_old_ctx;
 
        /*
         * We can not change UNC/username/password/domainname/
@@ -1244,6 +1242,7 @@ restore_ctx:
        kfree_sensitive(new_password2);
        smb3_cleanup_fs_context_contents(cifs_sb->ctx);
        memcpy(cifs_sb->ctx, old_ctx, sizeof(*old_ctx));
+free_old_ctx:
        kfree(old_ctx);
 
        return rc;