From: Rishabh Bhatnagar <risbhat@amazon.com>
To: <gregkh@linuxfoundation.org>, <pc@cjr.nz>
Cc: <stable@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-cifs@vger.kernel.org>, Aurelien Aptel <aaptel@suse.com>,
Steve French <stfrench@microsoft.com>,
Rishabh Bhatnagar <risbhat@amazon.com>
Subject: [PATCH 5.4 4/5] cifs: Merge is_path_valid() into get_normalized_path()
Date: Fri, 23 Jun 2023 21:34:05 +0000 [thread overview]
Message-ID: <20230623213406.5596-5-risbhat@amazon.com> (raw)
In-Reply-To: <20230623213406.5596-1-risbhat@amazon.com>
From: "Paulo Alcantara (SUSE)" <pc@cjr.nz>
commit ff2f7fc08268f266372c30a815349749e8499eb5 upstream.
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>
Signed-off-by: Rishabh Bhatnagar <risbhat@amazon.com>
---
fs/cifs/dfs_cache.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
index 31b3dc09e109..1efba8ee86bf 100644
--- a/fs/cifs/dfs_cache.c
+++ b/fs/cifs/dfs_cache.c
@@ -75,13 +75,11 @@ static void refresh_cache_worker(struct work_struct *work);
static DECLARE_DELAYED_WORK(refresh_task, refresh_cache_worker);
-static inline bool is_path_valid(const char *path)
+static int get_normalized_path(const char *path, char **npath)
{
- return path && (strchr(path + 1, '\\') || strchr(path + 1, '/'));
-}
+ if (!path || strlen(path) < 3 || (*path != '\\' && *path != '/'))
+ return -EINVAL;
-static inline int get_normalized_path(const char *path, char **npath)
-{
if (*path == '\\') {
*npath = (char *)path;
} else {
@@ -828,9 +826,6 @@ int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses,
char *npath;
struct cache_entry *ce;
- if (unlikely(!is_path_valid(path)))
- return -EINVAL;
-
rc = get_normalized_path(path, &npath);
if (rc)
return rc;
@@ -875,9 +870,6 @@ int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
char *npath;
struct cache_entry *ce;
- if (unlikely(!is_path_valid(path)))
- return -EINVAL;
-
rc = get_normalized_path(path, &npath);
if (rc)
return rc;
@@ -929,9 +921,6 @@ int dfs_cache_update_tgthint(const unsigned int xid, struct cifs_ses *ses,
struct cache_entry *ce;
struct cache_dfs_tgt *t;
- if (unlikely(!is_path_valid(path)))
- return -EINVAL;
-
rc = get_normalized_path(path, &npath);
if (rc)
return rc;
@@ -989,7 +978,7 @@ int dfs_cache_noreq_update_tgthint(const char *path,
struct cache_entry *ce;
struct cache_dfs_tgt *t;
- if (unlikely(!is_path_valid(path)) || !it)
+ if (!it)
return -EINVAL;
rc = get_normalized_path(path, &npath);
@@ -1049,8 +1038,6 @@ int dfs_cache_get_tgt_referral(const char *path,
if (!it || !ref)
return -EINVAL;
- if (unlikely(!is_path_valid(path)))
- return -EINVAL;
rc = get_normalized_path(path, &npath);
if (rc)
--
2.40.1
next prev parent reply other threads:[~2023-06-23 21:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 21:34 [PATCH 5.4 0/5] CIFS DFS fixes for 5.4 Rishabh Bhatnagar
2023-06-23 21:34 ` [PATCH 5.4 1/5] cifs: Clean up DFS referral cache Rishabh Bhatnagar
2023-06-23 21:34 ` [PATCH 5.4 2/5] cifs: Get rid of kstrdup_const()'d paths Rishabh Bhatnagar
2023-06-25 15:38 ` David Laight
2023-06-25 16:58 ` Paulo Alcantara
2023-06-23 21:34 ` [PATCH 5.4 3/5] cifs: Introduce helpers for finding TCP connection Rishabh Bhatnagar
2023-06-26 6:04 ` Shyam Prasad N
2023-06-26 6:13 ` Greg KH
2023-06-26 6:30 ` Shyam Prasad N
2023-06-23 21:34 ` Rishabh Bhatnagar [this message]
2023-06-23 21:34 ` [PATCH 5.4 5/5] cifs: Fix potential deadlock when updating vol in cifs_reconnect() Rishabh Bhatnagar
2023-06-23 22:08 ` [PATCH 5.4 0/5] CIFS DFS fixes for 5.4 Paulo Alcantara
2023-06-24 14:10 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230623213406.5596-5-risbhat@amazon.com \
--to=risbhat@amazon.com \
--cc=aaptel@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@cjr.nz \
--cc=stable@vger.kernel.org \
--cc=stfrench@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.