Skip to content

Commit ff2f7fc

Browse files
Paulo Alcantara (SUSE)smfrench
authored andcommitted
cifs: Merge is_path_valid() into get_normalized_path()
Just do the trivial path validation in get_normalized_path(). Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 345c1a4 commit ff2f7fc

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

‎fs/cifs/dfs_cache.c‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,11 @@ static void refresh_cache_worker(struct work_struct *work);
7575

7676
static DECLARE_DELAYED_WORK(refresh_task, refresh_cache_worker);
7777

78-
static inline bool is_path_valid(const char *path)
78+
static int get_normalized_path(const char *path, char **npath)
7979
{
80-
return path && (strchr(path + 1, '\\') || strchr(path + 1, '/'));
81-
}
80+
if (!path || strlen(path) < 3 || (*path != '\\' && *path != '/'))
81+
return -EINVAL;
8282

83-
static inline int get_normalized_path(const char *path, char **npath)
84-
{
8583
if (*path == '\\') {
8684
*npath = (char *)path;
8785
} else {
@@ -828,9 +826,6 @@ int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses,
828826
char *npath;
829827
struct cache_entry *ce;
830828

831-
if (unlikely(!is_path_valid(path)))
832-
return -EINVAL;
833-
834829
rc = get_normalized_path(path, &npath);
835830
if (rc)
836831
return rc;
@@ -875,9 +870,6 @@ int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
875870
char *npath;
876871
struct cache_entry *ce;
877872

878-
if (unlikely(!is_path_valid(path)))
879-
return -EINVAL;
880-
881873
rc = get_normalized_path(path, &npath);
882874
if (rc)
883875
return rc;
@@ -929,9 +921,6 @@ int dfs_cache_update_tgthint(const unsigned int xid, struct cifs_ses *ses,
929921
struct cache_entry *ce;
930922
struct cache_dfs_tgt *t;
931923

932-
if (unlikely(!is_path_valid(path)))
933-
return -EINVAL;
934-
935924
rc = get_normalized_path(path, &npath);
936925
if (rc)
937926
return rc;
@@ -989,7 +978,7 @@ int dfs_cache_noreq_update_tgthint(const char *path,
989978
struct cache_entry *ce;
990979
struct cache_dfs_tgt *t;
991980

992-
if (unlikely(!is_path_valid(path)) || !it)
981+
if (!it)
993982
return -EINVAL;
994983

995984
rc = get_normalized_path(path, &npath);
@@ -1049,8 +1038,6 @@ int dfs_cache_get_tgt_referral(const char *path,
10491038

10501039
if (!it || !ref)
10511040
return -EINVAL;
1052-
if (unlikely(!is_path_valid(path)))
1053-
return -EINVAL;
10541041

10551042
rc = get_normalized_path(path, &npath);
10561043
if (rc)

0 commit comments

Comments
 (0)