Message ID | 20240701064847.84726-1-make24@iscas.ac.cn |
---|---|
State | New |
Headers | show |
Series | fs: smb: client: Add missing check for kstrdup() | expand |
> Add check for kstrdup() in smb3_reconfigure in order to guarantee checks? calls? () > the success of allocation. I suggest to take further patch/code review concerns better into account. … > Signed-off-by: Haoxiang Li <make24@iscas.ac.cn> Will requirements be reconsidered once more for the Developer's Certificate of Origin? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc6#n398 How do you think about to use a summary phrase like “Complete error handling in smb3_reconfigure()”? … > +++ 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); > } … How do you think about to avoid also a memory leak here? Regards, Markus
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);
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(+)