Skip to content

Commit

Permalink
cifs: fix potential double free during failed mount
Browse files Browse the repository at this point in the history
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2088799

Cc: stable@vger.kernel.org
Signed-off-by: Roberto Bergantinos <rbergant@redhat.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Ronnie Sahlberg authored and Steve French committed May 31, 2022
1 parent bf27246 commit 8378a51
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
int flags, struct smb3_fs_context *old_ctx)
{
int rc;
struct super_block *sb;
struct super_block *sb = NULL;
struct cifs_sb_info *cifs_sb = NULL;
struct cifs_mnt_data mnt_data;
struct dentry *root;
Expand Down Expand Up @@ -934,9 +934,11 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
return root;
out:
if (cifs_sb) {
kfree(cifs_sb->prepath);
smb3_cleanup_fs_context(cifs_sb->ctx);
kfree(cifs_sb);
if (!sb || IS_ERR(sb)) { /* otherwise kill_sb will handle */
kfree(cifs_sb->prepath);
smb3_cleanup_fs_context(cifs_sb->ctx);
kfree(cifs_sb);
}
}
return root;
}
Expand Down

0 comments on commit 8378a51

Please sign in to comment.