Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] fs: smb: client: Add missing check for kstrdup()
@ 2024-07-01  6:48 Haoxiang Li
  2024-07-01 13:01 ` Markus Elfring
  0 siblings, 1 reply; 6+ messages in thread
From: Haoxiang Li @ 2024-07-01  6:48 UTC (permalink / raw)
  To: sfrench, pc, ronniesahlberg, sprasad, tom, bharathsm
  Cc: linux-cifs, samba-technical, linux-kernel, Haoxiang Li

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@iscas.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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-04 11:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01  6:48 [PATCH] fs: smb: client: Add missing check for kstrdup() Haoxiang Li
2024-07-01 13:01 ` Markus Elfring
2024-10-22 17:15   ` [PATCH v2] fs_context.c: smb3_reconfigure: Handle kstrdup failures for passwords Henrique Carvalho
2024-10-22 18:21     ` [PATCH v3] smb: client: " Henrique Carvalho
2024-10-22 22:21       ` Steve French
2024-11-04 11:06       ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox