* [PATCH] cifs: fix potential double free during failed mount
@ 2022-05-31 3:01 Ronnie Sahlberg
2022-05-31 4:06 ` Steve French
0 siblings, 1 reply; 2+ messages in thread
From: Ronnie Sahlberg @ 2022-05-31 3:01 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2088799
Signed-off-by: Roberto Bergantinos <rbergant@redhat.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifsfs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index f539a39d47f5..12c872800326 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -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;
@@ -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;
}
--
2.35.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cifs: fix potential double free during failed mount
2022-05-31 3:01 [PATCH] cifs: fix potential double free during failed mount Ronnie Sahlberg
@ 2022-05-31 4:06 ` Steve French
0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2022-05-31 4:06 UTC (permalink / raw)
To: Ronnie Sahlberg; +Cc: linux-cifs
added cc:stable and merged into cifs-2.6.git for-next
On Mon, May 30, 2022 at 10:01 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2088799
>
> Signed-off-by: Roberto Bergantinos <rbergant@redhat.com>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
> fs/cifs/cifsfs.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index f539a39d47f5..12c872800326 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -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;
> @@ -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;
> }
> --
> 2.35.3
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-31 4:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31 3:01 [PATCH] cifs: fix potential double free during failed mount Ronnie Sahlberg
2022-05-31 4:06 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).