Skip to content

Commit 8378a51

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: fix potential double free during failed mount
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2088799 Cc: [email protected] Signed-off-by: Roberto Bergantinos <[email protected]> Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent bf27246 commit 8378a51

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/cifs/cifsfs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
838838
int flags, struct smb3_fs_context *old_ctx)
839839
{
840840
int rc;
841-
struct super_block *sb;
841+
struct super_block *sb = NULL;
842842
struct cifs_sb_info *cifs_sb = NULL;
843843
struct cifs_mnt_data mnt_data;
844844
struct dentry *root;
@@ -934,9 +934,11 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
934934
return root;
935935
out:
936936
if (cifs_sb) {
937-
kfree(cifs_sb->prepath);
938-
smb3_cleanup_fs_context(cifs_sb->ctx);
939-
kfree(cifs_sb);
937+
if (!sb || IS_ERR(sb)) { /* otherwise kill_sb will handle */
938+
kfree(cifs_sb->prepath);
939+
smb3_cleanup_fs_context(cifs_sb->ctx);
940+
kfree(cifs_sb);
941+
}
940942
}
941943
return root;
942944
}

0 commit comments

Comments
 (0)