]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
smb: client: get rid of kstrdup() in get_ses_refpath()
authorPaulo Alcantara <pc@manguebit.com>
Wed, 5 Feb 2025 16:41:32 +0000 (13:41 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 6 Feb 2025 03:09:07 +0000 (21:09 -0600)
After commit 36008fe6e3dc ("smb: client: don't try following DFS links
in cifs_tree_connect()"), TCP_Server_Info::leaf_fullpath will no
longer be changed, so there is no need to kstrdup() it.

Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/dfs.h
fs/smb/client/dfs_cache.c

index ed4cd7cf1ec645a9fa8b6910d44ccfeb4ceaed05..e60f0a24a8a1da243ce4b875831e931e99ee97ac 100644 (file)
@@ -188,4 +188,11 @@ static inline void dfs_put_root_smb_sessions(struct list_head *head)
        }
 }
 
+static inline const char *dfs_ses_refpath(struct cifs_ses *ses)
+{
+       const char *path = ses->server->leaf_fullpath;
+
+       return path ? path + 1 : ERR_PTR(-ENOENT);
+}
+
 #endif /* _CIFS_DFS_H */
index 5022bb1f122a1088beceef8fd7ab7fd8ff514f23..4dada26d56b5fe246e960b158244fbc934792c68 100644 (file)
@@ -1136,33 +1136,19 @@ static bool is_ses_good(struct cifs_ses *ses)
        return ret;
 }
 
-static char *get_ses_refpath(struct cifs_ses *ses)
-{
-       struct TCP_Server_Info *server = ses->server;
-       char *path = ERR_PTR(-ENOENT);
-
-       if (server->leaf_fullpath) {
-               path = kstrdup(server->leaf_fullpath + 1, GFP_KERNEL);
-               if (!path)
-                       path = ERR_PTR(-ENOMEM);
-       }
-       return path;
-}
-
 /* Refresh dfs referral of @ses */
 static void refresh_ses_referral(struct cifs_ses *ses)
 {
        struct cache_entry *ce;
        unsigned int xid;
-       char *path;
+       const char *path;
        int rc = 0;
 
        xid = get_xid();
 
-       path = get_ses_refpath(ses);
+       path = dfs_ses_refpath(ses);
        if (IS_ERR(path)) {
                rc = PTR_ERR(path);
-               path = NULL;
                goto out;
        }
 
@@ -1181,7 +1167,6 @@ static void refresh_ses_referral(struct cifs_ses *ses)
 
 out:
        free_xid(xid);
-       kfree(path);
 }
 
 static int __refresh_tcon_referral(struct cifs_tcon *tcon,
@@ -1231,19 +1216,18 @@ static void refresh_tcon_referral(struct cifs_tcon *tcon, bool force_refresh)
        struct dfs_info3_param *refs = NULL;
        struct cache_entry *ce;
        struct cifs_ses *ses;
-       unsigned int xid;
        bool needs_refresh;
-       char *path;
+       const char *path;
+       unsigned int xid;
        int numrefs = 0;
        int rc = 0;
 
        xid = get_xid();
        ses = tcon->ses;
 
-       path = get_ses_refpath(ses);
+       path = dfs_ses_refpath(ses);
        if (IS_ERR(path)) {
                rc = PTR_ERR(path);
-               path = NULL;
                goto out;
        }
 
@@ -1271,7 +1255,6 @@ static void refresh_tcon_referral(struct cifs_tcon *tcon, bool force_refresh)
 
 out:
        free_xid(xid);
-       kfree(path);
        free_dfs_info_array(refs, numrefs);
 }