Skip to content

Commit be1963d

Browse files
pcacjrSteve French
authored and
Steve French
committed
smb: client: get rid of kstrdup() in get_ses_refpath()
After commit 36008fe ("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) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 773dc23 commit be1963d

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

fs/smb/client/dfs.h

+7
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,11 @@ static inline void dfs_put_root_smb_sessions(struct list_head *head)
188188
}
189189
}
190190

191+
static inline const char *dfs_ses_refpath(struct cifs_ses *ses)
192+
{
193+
const char *path = ses->server->leaf_fullpath;
194+
195+
return path ? path + 1 : ERR_PTR(-ENOENT);
196+
}
197+
191198
#endif /* _CIFS_DFS_H */

fs/smb/client/dfs_cache.c

+5-22
Original file line numberDiff line numberDiff line change
@@ -1136,33 +1136,19 @@ static bool is_ses_good(struct cifs_ses *ses)
11361136
return ret;
11371137
}
11381138

1139-
static char *get_ses_refpath(struct cifs_ses *ses)
1140-
{
1141-
struct TCP_Server_Info *server = ses->server;
1142-
char *path = ERR_PTR(-ENOENT);
1143-
1144-
if (server->leaf_fullpath) {
1145-
path = kstrdup(server->leaf_fullpath + 1, GFP_KERNEL);
1146-
if (!path)
1147-
path = ERR_PTR(-ENOMEM);
1148-
}
1149-
return path;
1150-
}
1151-
11521139
/* Refresh dfs referral of @ses */
11531140
static void refresh_ses_referral(struct cifs_ses *ses)
11541141
{
11551142
struct cache_entry *ce;
11561143
unsigned int xid;
1157-
char *path;
1144+
const char *path;
11581145
int rc = 0;
11591146

11601147
xid = get_xid();
11611148

1162-
path = get_ses_refpath(ses);
1149+
path = dfs_ses_refpath(ses);
11631150
if (IS_ERR(path)) {
11641151
rc = PTR_ERR(path);
1165-
path = NULL;
11661152
goto out;
11671153
}
11681154

@@ -1181,7 +1167,6 @@ static void refresh_ses_referral(struct cifs_ses *ses)
11811167

11821168
out:
11831169
free_xid(xid);
1184-
kfree(path);
11851170
}
11861171

11871172
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)
12311216
struct dfs_info3_param *refs = NULL;
12321217
struct cache_entry *ce;
12331218
struct cifs_ses *ses;
1234-
unsigned int xid;
12351219
bool needs_refresh;
1236-
char *path;
1220+
const char *path;
1221+
unsigned int xid;
12371222
int numrefs = 0;
12381223
int rc = 0;
12391224

12401225
xid = get_xid();
12411226
ses = tcon->ses;
12421227

1243-
path = get_ses_refpath(ses);
1228+
path = dfs_ses_refpath(ses);
12441229
if (IS_ERR(path)) {
12451230
rc = PTR_ERR(path);
1246-
path = NULL;
12471231
goto out;
12481232
}
12491233

@@ -1271,7 +1255,6 @@ static void refresh_tcon_referral(struct cifs_tcon *tcon, bool force_refresh)
12711255

12721256
out:
12731257
free_xid(xid);
1274-
kfree(path);
12751258
free_dfs_info_array(refs, numrefs);
12761259
}
12771260

0 commit comments

Comments
 (0)