ksmbd: missing check for NULL in convert_to_nt_pathname()

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>
Acked-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by Dan Carpenter and committed by Steve French 87ffb310 4227f811

+7 -10
+7 -10
fs/ksmbd/misc.c
··· 162 162 { 163 163 char *ab_pathname; 164 164 165 - if (strlen(filename) == 0) { 166 - ab_pathname = kmalloc(2, GFP_KERNEL); 167 - ab_pathname[0] = '\\'; 168 - ab_pathname[1] = '\0'; 169 - } else { 170 - ab_pathname = kstrdup(filename, GFP_KERNEL); 171 - if (!ab_pathname) 172 - return NULL; 165 + if (strlen(filename) == 0) 166 + filename = "\\"; 173 167 174 - ksmbd_conv_path_to_windows(ab_pathname); 175 - } 168 + ab_pathname = kstrdup(filename, GFP_KERNEL); 169 + if (!ab_pathname) 170 + return NULL; 171 + 172 + ksmbd_conv_path_to_windows(ab_pathname); 176 173 return ab_pathname; 177 174 } 178 175