mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
smb: client: fix warning in cifs_smb3_do_mount()
[ Upstream commit 12c30f33cc ]
This fixes the following warning reported by kernel test robot
fs/smb/client/cifsfs.c:982 cifs_smb3_do_mount() warn: possible
memory leak of 'cifs_sb'
Link: https://lore.kernel.org/all/202306170124.CtQqzf0I-lkp@intel.com/
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a783230585
commit
945f4a7aff
@@ -883,11 +883,11 @@ struct dentry *
|
|||||||
cifs_smb3_do_mount(struct file_system_type *fs_type,
|
cifs_smb3_do_mount(struct file_system_type *fs_type,
|
||||||
int flags, struct smb3_fs_context *old_ctx)
|
int flags, struct smb3_fs_context *old_ctx)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
struct super_block *sb = NULL;
|
|
||||||
struct cifs_sb_info *cifs_sb = NULL;
|
|
||||||
struct cifs_mnt_data mnt_data;
|
struct cifs_mnt_data mnt_data;
|
||||||
|
struct cifs_sb_info *cifs_sb;
|
||||||
|
struct super_block *sb;
|
||||||
struct dentry *root;
|
struct dentry *root;
|
||||||
|
int rc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints in Kernel / CIFS log the attempted mount operation
|
* Prints in Kernel / CIFS log the attempted mount operation
|
||||||
@@ -898,11 +898,9 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
|
|||||||
else
|
else
|
||||||
cifs_info("Attempting to mount %s\n", old_ctx->UNC);
|
cifs_info("Attempting to mount %s\n", old_ctx->UNC);
|
||||||
|
|
||||||
cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
|
cifs_sb = kzalloc(sizeof(*cifs_sb), GFP_KERNEL);
|
||||||
if (cifs_sb == NULL) {
|
if (!cifs_sb)
|
||||||
root = ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
cifs_sb->ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
|
cifs_sb->ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
|
||||||
if (!cifs_sb->ctx) {
|
if (!cifs_sb->ctx) {
|
||||||
@@ -945,10 +943,8 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
|
|||||||
|
|
||||||
sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data);
|
sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data);
|
||||||
if (IS_ERR(sb)) {
|
if (IS_ERR(sb)) {
|
||||||
root = ERR_CAST(sb);
|
|
||||||
cifs_umount(cifs_sb);
|
cifs_umount(cifs_sb);
|
||||||
cifs_sb = NULL;
|
return ERR_CAST(sb);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sb->s_root) {
|
if (sb->s_root) {
|
||||||
@@ -979,13 +975,9 @@ out_super:
|
|||||||
deactivate_locked_super(sb);
|
deactivate_locked_super(sb);
|
||||||
return root;
|
return root;
|
||||||
out:
|
out:
|
||||||
if (cifs_sb) {
|
kfree(cifs_sb->prepath);
|
||||||
if (!sb || IS_ERR(sb)) { /* otherwise kill_sb will handle */
|
smb3_cleanup_fs_context(cifs_sb->ctx);
|
||||||
kfree(cifs_sb->prepath);
|
kfree(cifs_sb);
|
||||||
smb3_cleanup_fs_context(cifs_sb->ctx);
|
|
||||||
kfree(cifs_sb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user