* [PATCH] ext2: super: remove unnecessary goto statement
@ 2014-05-07 16:08 Seunghun Lee
2014-05-12 12:56 ` Lukáš Czerner
0 siblings, 1 reply; 2+ messages in thread
From: Seunghun Lee @ 2014-05-07 16:08 UTC (permalink / raw)
To: jack; +Cc: linux-ext4, linux-kernel, Seunghun Lee
This patch removes unnecessary goto failed,
and moves kfree to failed.
Signed-off-by: Seunghun Lee <waydi1@gmail.com>
---
fs/ext2/super.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 3750031..7d20a50 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -777,17 +777,15 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
__le32 features;
int err;
- err = -ENOMEM;
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
- goto failed;
+ return -ENOMEM;
sbi->s_blockgroup_lock =
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
- if (!sbi->s_blockgroup_lock) {
- kfree(sbi);
+ if (!sbi->s_blockgroup_lock)
goto failed;
- }
+
sb->s_fs_info = sbi;
sbi->s_sb_block = sb_block;
@@ -1138,8 +1136,8 @@ failed_mount:
failed_sbi:
sb->s_fs_info = NULL;
kfree(sbi->s_blockgroup_lock);
- kfree(sbi);
failed:
+ kfree(sbi);
return ret;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext2: super: remove unnecessary goto statement
2014-05-07 16:08 [PATCH] ext2: super: remove unnecessary goto statement Seunghun Lee
@ 2014-05-12 12:56 ` Lukáš Czerner
0 siblings, 0 replies; 2+ messages in thread
From: Lukáš Czerner @ 2014-05-12 12:56 UTC (permalink / raw)
To: Seunghun Lee; +Cc: jack, linux-ext4, linux-kernel
On Thu, 8 May 2014, Seunghun Lee wrote:
> Date: Thu, 8 May 2014 01:08:03 +0900
> From: Seunghun Lee <waydi1@gmail.com>
> To: jack@suse.cz
> Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
> Seunghun Lee <waydi1@gmail.com>
> Subject: [PATCH] ext2: super: remove unnecessary goto statement
>
> This patch removes unnecessary goto failed,
> and moves kfree to failed.
>
> Signed-off-by: Seunghun Lee <waydi1@gmail.com>
> ---
> fs/ext2/super.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 3750031..7d20a50 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -777,17 +777,15 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> __le32 features;
> int err;
>
> - err = -ENOMEM;
The problem here is actually that we return -EINVAL while we should
actually return -ENOMEM, which is fixed only partially by your
patch.
Also there are number other problems in error handling here mainly
because we're using err variable but not setting ret variable which
is the one that we return eventually.
Also ret is defined as long (not sure if that's needed) but the
function is supposed to return int.
So if you're changing the code around it would be good to actually
fix some problems as well :)
Thanks!
-Lukas
> sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
> if (!sbi)
> - goto failed;
> + return -ENOMEM;
>
> sbi->s_blockgroup_lock =
> kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
> - if (!sbi->s_blockgroup_lock) {
> - kfree(sbi);
> + if (!sbi->s_blockgroup_lock)
> goto failed;
> - }
> +
> sb->s_fs_info = sbi;
> sbi->s_sb_block = sb_block;
>
> @@ -1138,8 +1136,8 @@ failed_mount:
> failed_sbi:
> sb->s_fs_info = NULL;
> kfree(sbi->s_blockgroup_lock);
> - kfree(sbi);
> failed:
> + kfree(sbi);
> return ret;
> }
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-12 12:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 16:08 [PATCH] ext2: super: remove unnecessary goto statement Seunghun Lee
2014-05-12 12:56 ` Lukáš Czerner
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).