Patchwork ext4: Fix missing iput for root inode in case of all failed mount paths.

login
register
mail settings
Submitter Manish Katiyar
Date Jan. 16, 2011, 7:30 a.m.
Message ID <AANLkTik8jweuA_kDfzY7H=wP-ikSSwdf-FF1NX09DDCT@mail.gmail.com>
Download mbox | patch
Permalink /patch/79077/
State New
Headers show

Comments

Manish Katiyar - Jan. 16, 2011, 7:30 a.m.
Fix missing iput for root inode in case of all failed mount paths.
Fixes bug#26752

Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>

---
 fs/ext4/super.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Andreas Dilger - Jan. 16, 2011, 4:20 p.m.
Why not just put the iput() at failed_mount4() instead of spread around the code?

Cheers, Andreas

On 2011-01-16, at 0:30, Manish Katiyar <mkatiyar@gmail.com> wrote:

> Fix missing iput for root inode in case of all failed mount paths.
> Fixes bug#26752
> 
> Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
> 
> ---
> fs/ext4/super.c |    8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index cb10a06..9570fcc 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -3587,6 +3587,7 @@ no_journal:
>        if (err) {
>                ext4_msg(sb, KERN_ERR, "failed to initialize system "
>                         "zone (%d)", err);
> +               iput(root);
>                goto failed_mount4;
>        }
> 
> @@ -3595,12 +3596,15 @@ no_journal:
>        if (err) {
>                ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
>                         err);
> +               iput(root);
>                goto failed_mount4;
>        }
> 
>        err = ext4_register_li_request(sb, first_not_zeroed);
> -       if (err)
> +       if (err) {
> +               iput(root);
>                goto failed_mount4;
> +       }
> 
>        sbi->s_kobj.kset = ext4_kset;
>        init_completion(&sbi->s_kobj_unregister);
> @@ -3609,6 +3613,7 @@ no_journal:
>        if (err) {
>                ext4_mb_release(sb);
>                ext4_ext_release(sb);
> +               iput(root);
>                goto failed_mount4;
>        };
> 
> @@ -3648,6 +3653,7 @@ cantfind_ext4:
>        goto failed_mount;
> 
> failed_mount4:
> +       sb->s_root = NULL;
>        ext4_msg(sb, KERN_ERR, "mount failed");
>        destroy_workqueue(EXT4_SB(sb)->dio_unwritten_wq);
> failed_mount_wq:
> -- 
> 1.7.1
> 
> 
> -- 
> Thanks -
> Manish
> ==================================
> [$\*.^ -- I miss being one of them
> ==================================
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index cb10a06..9570fcc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3587,6 +3587,7 @@  no_journal:
        if (err) {
                ext4_msg(sb, KERN_ERR, "failed to initialize system "
                         "zone (%d)", err);
+               iput(root);
                goto failed_mount4;
        }

@@ -3595,12 +3596,15 @@  no_journal:
        if (err) {
                ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
                         err);
+               iput(root);
                goto failed_mount4;
        }

        err = ext4_register_li_request(sb, first_not_zeroed);
-       if (err)
+       if (err) {
+               iput(root);
                goto failed_mount4;
+       }

        sbi->s_kobj.kset = ext4_kset;
        init_completion(&sbi->s_kobj_unregister);
@@ -3609,6 +3613,7 @@  no_journal:
        if (err) {
                ext4_mb_release(sb);
                ext4_ext_release(sb);
+               iput(root);
                goto failed_mount4;
        };

@@ -3648,6 +3653,7 @@  cantfind_ext4:
        goto failed_mount;

 failed_mount4:
+       sb->s_root = NULL;
        ext4_msg(sb, KERN_ERR, "mount failed");
        destroy_workqueue(EXT4_SB(sb)->dio_unwritten_wq);
 failed_mount_wq: