diff mbox series

ext4: handle unsuccessful sbi allocation

Message ID 20220125130604.26473-1-amhamza.mgc@gmail.com
State Handled Elsewhere
Headers show
Series ext4: handle unsuccessful sbi allocation | expand

Commit Message

Ameer Hamza Jan. 25, 2022, 1:06 p.m. UTC
Move to common fail path in case of unsuccessful sbi allocation

Addresses-Coverity: 1497833 ("Unused value")

Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
 fs/ext4/super.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Lukas Czerner Jan. 25, 2022, 1:36 p.m. UTC | #1
We already have a patch to fix the problem on this list

https://lore.kernel.org/linux-ext4/20220119130209.40112-1-lczerner@redhat.com/T/#u

-Lukas

On Tue, Jan 25, 2022 at 06:06:04PM +0500, Ameer Hamza wrote:
> Move to common fail path in case of unsuccessful sbi allocation
> 
> Addresses-Coverity: 1497833 ("Unused value")
> 
> Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
> ---
>  fs/ext4/super.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 57914acc5402..0dccf1ed931b 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5540,8 +5540,10 @@ static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
>  	int ret;
>  
>  	sbi = ext4_alloc_sbi(sb);
> -	if (!sbi)
> +	if (!sbi) {
>  		ret = -ENOMEM;
> +		goto free_sbi;
> +	}
>  
>  	fc->s_fs_info = sbi;
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 57914acc5402..0dccf1ed931b 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5540,8 +5540,10 @@  static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
 	int ret;
 
 	sbi = ext4_alloc_sbi(sb);
-	if (!sbi)
+	if (!sbi) {
 		ret = -ENOMEM;
+		goto free_sbi;
+	}
 
 	fc->s_fs_info = sbi;