Re: [PATCH] fs: smb: client: Add missing check for kstrdup()

From: Markus Elfring
Date: Mon Jul 01 2024 - 09:02:42 EST


> 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@xxxxxxxxxxx>

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