smb: client: Handle kstrdup failures for passwords
authorHenrique Carvalho <henrique.carvalho@suse.com>
Tue, 22 Oct 2024 18:21:26 +0000 (15:21 -0300)
committerSteve French <stfrench@microsoft.com>
Wed, 23 Oct 2024 12:42:22 +0000 (07:42 -0500)
commit9a5dd61151399ad5a5d69aad28ab164734c1e3bc
treefe31f832e4eb4f9582ef9922319188d01239cead
parent42f7652d3eb527d03665b09edac47f85fb600924
smb: client: Handle kstrdup failures for passwords

In smb3_reconfigure(), after duplicating ctx->password and
ctx->password2 with kstrdup(), we need to check for allocation
failures.

If ses->password allocation fails, return -ENOMEM.
If ses->password2 allocation fails, free ses->password, set it
to NULL, and return -ENOMEM.

Fixes: c1eb537bf456 ("cifs: allow changing password during remount")
Reviewed-by: David Howells <dhowells@redhat.com
Signed-off-by: Haoxiang Li <make24@iscas.ac.cn>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/fs_context.c