[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240701064847.84726-1-make24@iscas.ac.cn>
Date: Mon, 1 Jul 2024 14:48:47 +0800
From: Haoxiang Li <make24@...as.ac.cn>
To: sfrench@...ba.org,
pc@...guebit.com,
ronniesahlberg@...il.com,
sprasad@...rosoft.com,
tom@...pey.com,
bharathsm@...rosoft.com
Cc: linux-cifs@...r.kernel.org,
samba-technical@...ts.samba.org,
linux-kernel@...r.kernel.org,
Haoxiang Li <make24@...as.ac.cn>
Subject: [PATCH] fs: smb: client: Add missing check for kstrdup()
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@...as.ac.cn>
---
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
Powered by blists - more mailing lists