cifs: move cifs_cleanup_volume_info[_content] to fs_context.c

and rename it to smb3_cleanup_fs_context[_content]

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Ronnie Sahlberg 2020-12-14 16:40:16 +10:00 committed by Steve French
parent 427c4f004e
commit c741cba2cd
6 changed files with 51 additions and 52 deletions

View File

@ -874,7 +874,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
out:
if (cifs_sb) {
kfree(cifs_sb->prepath);
cifs_cleanup_volume_info(cifs_sb->ctx);
smb3_cleanup_fs_context(cifs_sb->ctx);
kfree(cifs_sb);
}
return root;

View File

@ -237,7 +237,6 @@ extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
struct cifs_sb_info *cifs_sb);
extern int cifs_match_super(struct super_block *, void *);
extern void cifs_cleanup_volume_info(struct smb3_fs_context *ctx);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
extern void cifs_umount(struct cifs_sb_info *);
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
@ -552,8 +551,6 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
extern int
cifs_setup_volume_info(struct smb3_fs_context *ctx);
extern void
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx);
extern struct TCP_Server_Info *
cifs_find_tcp_session(struct smb3_fs_context *ctx);

View File

@ -2820,45 +2820,6 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
return 0;
}
void
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx)
{
if (ctx == NULL)
return;
/*
* Make sure this stays in sync with smb3_fs_context_dup()
*/
kfree(ctx->mount_options);
ctx->mount_options = NULL;
kfree(ctx->username);
ctx->username = NULL;
kfree_sensitive(ctx->password);
ctx->password = NULL;
kfree(ctx->UNC);
ctx->UNC = NULL;
kfree(ctx->domainname);
ctx->domainname = NULL;
kfree(ctx->nodename);
ctx->nodename = NULL;
kfree(ctx->iocharset);
ctx->iocharset = NULL;
kfree(ctx->prepath);
ctx->prepath = NULL;
unload_nls(ctx->local_nls);
ctx->local_nls = NULL;
}
void
cifs_cleanup_volume_info(struct smb3_fs_context *ctx)
{
if (!ctx)
return;
cifs_cleanup_volume_info_contents(ctx);
kfree(ctx);
}
/* Release all succeed connections */
static inline void mount_put_conns(struct cifs_sb_info *cifs_sb,
unsigned int xid,
@ -3069,7 +3030,7 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
rc = PTR_ERR(mdata);
mdata = NULL;
} else {
cifs_cleanup_volume_info_contents(ctx);
smb3_cleanup_fs_context_contents(ctx);
rc = cifs_setup_volume_info(ctx);
}
kfree(cifs_sb->ctx->mount_options);
@ -3161,7 +3122,7 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path,
rc = update_vol_info(tgt_it, &fake_ctx, ctx);
}
}
cifs_cleanup_volume_info_contents(&fake_ctx);
smb3_cleanup_fs_context_contents(&fake_ctx);
return rc;
}
@ -3409,7 +3370,7 @@ static int check_dfs_prepath(struct cifs_sb_info *cifs_sb, struct smb3_fs_contex
break;
rc = -EREMOTE;
npath = build_unc_path_to_root(&v, cifs_sb, true);
cifs_cleanup_volume_info_contents(&v);
smb3_cleanup_fs_context_contents(&v);
} else {
v.UNC = ctx->UNC;
v.prepath = path + 1;
@ -3773,7 +3734,7 @@ static void delayed_free(struct rcu_head *p)
struct cifs_sb_info *cifs_sb = container_of(p, struct cifs_sb_info, rcu);
unload_nls(cifs_sb->local_nls);
cifs_cleanup_volume_info(cifs_sb->ctx);
smb3_cleanup_fs_context(cifs_sb->ctx);
kfree(cifs_sb);
}

View File

@ -587,7 +587,7 @@ static void __vol_release(struct vol_info *vi)
{
kfree(vi->fullpath);
kfree(vi->mntdata);
cifs_cleanup_volume_info_contents(&vi->ctx);
smb3_cleanup_fs_context_contents(&vi->ctx);
kfree(vi);
}
@ -1468,7 +1468,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi,
ses = cifs_get_smb_ses(server, &ctx);
out:
cifs_cleanup_volume_info_contents(&ctx);
smb3_cleanup_fs_context_contents(&ctx);
kfree(mdata);
kfree(rpath);

View File

@ -290,7 +290,7 @@ do { \
if (ctx->field) { \
new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC); \
if (new_ctx->field == NULL) { \
cifs_cleanup_volume_info_contents(new_ctx); \
smb3_cleanup_fs_context_contents(new_ctx); \
return -ENOMEM; \
} \
} \
@ -313,7 +313,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
new_ctx->iocharset = NULL;
/*
* Make sure to stay in sync with cifs_cleanup_volume_info_contents()
* Make sure to stay in sync with smb3_cleanup_fs_context_contents()
*/
DUP_CTX_STR(prepath);
DUP_CTX_STR(mount_options);
@ -618,7 +618,7 @@ static void smb3_fs_context_free(struct fs_context *fc)
{
struct smb3_fs_context *ctx = smb3_fc2context(fc);
cifs_cleanup_volume_info(ctx);
smb3_cleanup_fs_context(ctx);
}
static int smb3_reconfigure(struct fs_context *fc)
@ -1244,3 +1244,42 @@ int smb3_init_fs_context(struct fs_context *fc)
fc->ops = &smb3_fs_context_ops;
return 0;
}
void
smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
{
if (ctx == NULL)
return;
/*
* Make sure this stays in sync with smb3_fs_context_dup()
*/
kfree(ctx->mount_options);
ctx->mount_options = NULL;
kfree(ctx->username);
ctx->username = NULL;
kfree_sensitive(ctx->password);
ctx->password = NULL;
kfree(ctx->UNC);
ctx->UNC = NULL;
kfree(ctx->domainname);
ctx->domainname = NULL;
kfree(ctx->nodename);
ctx->nodename = NULL;
kfree(ctx->iocharset);
ctx->iocharset = NULL;
kfree(ctx->prepath);
ctx->prepath = NULL;
unload_nls(ctx->local_nls);
ctx->local_nls = NULL;
}
void
smb3_cleanup_fs_context(struct smb3_fs_context *ctx)
{
if (!ctx)
return;
smb3_cleanup_fs_context_contents(ctx);
kfree(ctx);
}

View File

@ -254,6 +254,8 @@ extern int cifs_parse_cache_flavor(char *value,
extern int cifs_parse_security_flavors(char *value,
struct smb3_fs_context *ctx);
extern int smb3_init_fs_context(struct fs_context *fc);
extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
{