Add check for kstrdup() in smb3_reconfigure in order to guarantee the success of allocation. Fixes: c1eb537bf456 ("cifs: allow changing password during remount") Signed-off-by: Haoxiang Li <make24@xxxxxxxxxxx> --- fs/smb/client/fs_context.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c index 3bbac925d076..8253b615b8ce 100644 --- a/fs/smb/client/fs_context.c +++ b/fs/smb/client/fs_context.c @@ -920,6 +920,8 @@ static int smb3_reconfigure(struct fs_context *fc) ses->password = kstrdup(ctx->password, GFP_KERNEL); kfree_sensitive(ses->password2); ses->password2 = kstrdup(ctx->password2, GFP_KERNEL); + if (!ses->password || !ses->password2) + return ERR_PTR(rc); } STEAL_STRING(cifs_sb, ctx, domainname); STEAL_STRING(cifs_sb, ctx, nodename); -- 2.25.1