Skip to content

Commit

Permalink
smb3 client: minor cleanup of username parsing on mount
Browse files Browse the repository at this point in the history
Minor improvement to checking and allocating username on mount.

Suggested-by: David Howells <dhowells@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Steve French committed Oct 25, 2024
1 parent c71f8fb commit 1646a18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/smb/client/fs_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
ctx->username = NULL;
if (ctx->nullauth)
break;
if (strlen(param->string) == 0) {

/* if first character is null, then anonymous auth */
if (*(param->string) == 0) {
/* null user, ie. anonymous authentication */
ctx->nullauth = 1;
break;
Expand All @@ -1299,11 +1301,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
pr_warn("username too long\n");
goto cifs_parse_mount_err;
}
ctx->username = kstrdup(param->string, GFP_KERNEL);
if (ctx->username == NULL) {
cifs_errorf(fc, "OOM when copying username string\n");
goto cifs_parse_mount_err;
}
ctx->username = param->string, GFP_KERNEL;
/* streal string from caller, but set to NULL so caller doesn't free */
param->string == NULL;
break;
case Opt_pass:
kfree_sensitive(ctx->password);
Expand Down

0 comments on commit 1646a18

Please sign in to comment.