diff options
author | Sebastian Reichel <sebastian.reichel@collabora.com> | 2022-05-22 23:03:29 +0200 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2022-05-22 23:03:29 +0200 |
commit | da50aad6d86716aa48a2b8463c85caea77c0355f (patch) | |
tree | c9604cc380e99e613c25ec06cbfcd5009c4575ba /fs/ksmbd/misc.c | |
parent | power: supply: bq24190_charger: using pm_runtime_resume_and_get instead of pm... (diff) | |
parent | power: supply: ab8500_fg: Allocate wq in probe (diff) | |
download | linux-da50aad6d86716aa48a2b8463c85caea77c0355f.tar.xz linux-da50aad6d86716aa48a2b8463c85caea77c0355f.zip |
Merge power-supply 'fixes' branch
Merge power-supply fixes, that missed the v5.18 merge window
into power-supply's for-next branch.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'fs/ksmbd/misc.c')
-rw-r--r-- | fs/ksmbd/misc.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/fs/ksmbd/misc.c b/fs/ksmbd/misc.c index 60e7ac62c917..1e2076a53bed 100644 --- a/fs/ksmbd/misc.c +++ b/fs/ksmbd/misc.c @@ -158,19 +158,41 @@ out: * Return : windows path string or error */ -char *convert_to_nt_pathname(char *filename) +char *convert_to_nt_pathname(struct ksmbd_share_config *share, + struct path *path) { - char *ab_pathname; + char *pathname, *ab_pathname, *nt_pathname; + int share_path_len = share->path_sz; - if (strlen(filename) == 0) - filename = "\\"; + pathname = kmalloc(PATH_MAX, GFP_KERNEL); + if (!pathname) + return ERR_PTR(-EACCES); - ab_pathname = kstrdup(filename, GFP_KERNEL); - if (!ab_pathname) - return NULL; + ab_pathname = d_path(path, pathname, PATH_MAX); + if (IS_ERR(ab_pathname)) { + nt_pathname = ERR_PTR(-EACCES); + goto free_pathname; + } + + if (strncmp(ab_pathname, share->path, share_path_len)) { + nt_pathname = ERR_PTR(-EACCES); + goto free_pathname; + } + + nt_pathname = kzalloc(strlen(&ab_pathname[share_path_len]) + 2, GFP_KERNEL); + if (!nt_pathname) { + nt_pathname = ERR_PTR(-ENOMEM); + goto free_pathname; + } + if (ab_pathname[share_path_len] == '\0') + strcpy(nt_pathname, "/"); + strcat(nt_pathname, &ab_pathname[share_path_len]); + + ksmbd_conv_path_to_windows(nt_pathname); - ksmbd_conv_path_to_windows(ab_pathname); - return ab_pathname; +free_pathname: + kfree(pathname); + return nt_pathname; } int get_nlink(struct kstat *st) |