The kmalloc() does not have a NULL check. This code can be re-written
slightly cleaner to just use the kstrdup().
Fixes: 74ebf2bc881f ("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>
Acked-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
{
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;
}