linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ksmbd: missing check for NULL in convert_to_nt_pathname()
@ 2021-09-30 12:24 Dan Carpenter
  2021-09-30 23:21 ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-09-30 12:24 UTC (permalink / raw)
  To: Namjae Jeon, Hyunchul Lee
  Cc: Sergey Senozhatsky, Steve French, linux-cifs, kernel-janitors

The kmalloc() does not have a NULL check.  This code can be re-written
slightly cleaner to just use the kstrdup().

Fixes: 265fd1991c1d ("ksmbd: use LOOKUP_BENEATH to prevent the out of share access")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/ksmbd/misc.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/ksmbd/misc.c b/fs/ksmbd/misc.c
index 6a19f4bc692d..60e7ac62c917 100644
--- a/fs/ksmbd/misc.c
+++ b/fs/ksmbd/misc.c
@@ -162,17 +162,14 @@ char *convert_to_nt_pathname(char *filename)
 {
 	char *ab_pathname;
 
-	if (strlen(filename) == 0) {
-		ab_pathname = kmalloc(2, GFP_KERNEL);
-		ab_pathname[0] = '\\';
-		ab_pathname[1] = '\0';
-	} else {
-		ab_pathname = kstrdup(filename, GFP_KERNEL);
-		if (!ab_pathname)
-			return NULL;
+	if (strlen(filename) == 0)
+		filename = "\\";
 
-		ksmbd_conv_path_to_windows(ab_pathname);
-	}
+	ab_pathname = kstrdup(filename, GFP_KERNEL);
+	if (!ab_pathname)
+		return NULL;
+
+	ksmbd_conv_path_to_windows(ab_pathname);
 	return ab_pathname;
 }
 
-- 
2.20.1


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

* Re: [PATCH] ksmbd: missing check for NULL in convert_to_nt_pathname()
  2021-09-30 12:24 [PATCH] ksmbd: missing check for NULL in convert_to_nt_pathname() Dan Carpenter
@ 2021-09-30 23:21 ` Namjae Jeon
  2021-10-01  1:01   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2021-09-30 23:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hyunchul Lee, Sergey Senozhatsky, Steve French, linux-cifs,
	kernel-janitors

2021-09-30 21:24 GMT+09:00, Dan Carpenter <dan.carpenter@oracle.com>:
> The kmalloc() does not have a NULL check.  This code can be re-written
> slightly cleaner to just use the kstrdup().
>
> Fixes: 265fd1991c1d ("ksmbd: use LOOKUP_BENEATH to prevent the out of share
> access")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>

Thanks for your patch!

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

* Re: [PATCH] ksmbd: missing check for NULL in convert_to_nt_pathname()
  2021-09-30 23:21 ` Namjae Jeon
@ 2021-10-01  1:01   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2021-10-01  1:01 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Dan Carpenter, Hyunchul Lee, Sergey Senozhatsky, Steve French,
	CIFS, kernel-janitors

Added the acked-bys and pushed to ksmbd-for-next

On Thu, Sep 30, 2021 at 6:23 PM Namjae Jeon <linkinjeon@kernel.org> wrote:
>
> 2021-09-30 21:24 GMT+09:00, Dan Carpenter <dan.carpenter@oracle.com>:
> > The kmalloc() does not have a NULL check.  This code can be re-written
> > slightly cleaner to just use the kstrdup().
> >
> > Fixes: 265fd1991c1d ("ksmbd: use LOOKUP_BENEATH to prevent the out of share
> > access")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Namjae Jeon <linkinjeon@kernel.org>
>
> Thanks for your patch!



-- 
Thanks,

Steve

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

end of thread, other threads:[~2021-10-01  1:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 12:24 [PATCH] ksmbd: missing check for NULL in convert_to_nt_pathname() Dan Carpenter
2021-09-30 23:21 ` Namjae Jeon
2021-10-01  1:01   ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).