diff mbox series

ext2: add missing brelse() in ext2_iget()

Message ID 20190616150801.2652-1-cgxu519@zoho.com.cn
State Not Applicable
Headers show
Series ext2: add missing brelse() in ext2_iget() | expand

Commit Message

Chengguang Xu June 16, 2019, 3:08 p.m. UTC
Add missing brelse() on error path of ext2_iget().

Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
---
 fs/ext2/inode.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Darrick Wong June 16, 2019, 4:45 p.m. UTC | #1
On Sun, Jun 16, 2019 at 11:08:01PM +0800, Chengguang Xu wrote:
> Add missing brelse() on error path of ext2_iget().
> 
> Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>

/me wonders if the brelse ought to be moved down to bad_inode so that
each error branch only has to set @ret and then jump (thereby
eliminating the possibility of making this mistake again), but for a
oneliner quick fix I guess it's fine:

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/ext2/inode.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index e474127dd255..fb3611f02051 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -1473,6 +1473,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
>  	else
>  		ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
>  	if (i_size_read(inode) < 0) {
> +		brelse(bh);
>  		ret = -EFSCORRUPTED;
>  		goto bad_inode;
>  	}
> -- 
> 2.21.0
> 
> 
>
Jan Kara June 19, 2019, 4:45 p.m. UTC | #2
On Sun 16-06-19 09:45:21, Darrick J. Wong wrote:
> On Sun, Jun 16, 2019 at 11:08:01PM +0800, Chengguang Xu wrote:
> > Add missing brelse() on error path of ext2_iget().
> > 
> > Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
> 
> /me wonders if the brelse ought to be moved down to bad_inode so that
> each error branch only has to set @ret and then jump (thereby
> eliminating the possibility of making this mistake again), but for a
> oneliner quick fix I guess it's fine:
> 
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

I've applied the fix and also the cleanup Darrick suggested (attached).

								Honza
> 
> --D
> 
> > ---
> >  fs/ext2/inode.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> > index e474127dd255..fb3611f02051 100644
> > --- a/fs/ext2/inode.c
> > +++ b/fs/ext2/inode.c
> > @@ -1473,6 +1473,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
> >  	else
> >  		ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
> >  	if (i_size_read(inode) < 0) {
> > +		brelse(bh);
> >  		ret = -EFSCORRUPTED;
> >  		goto bad_inode;
> >  	}
> > -- 
> > 2.21.0
> > 
> > 
> > 
>
diff mbox series

Patch

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index e474127dd255..fb3611f02051 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1473,6 +1473,7 @@  struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
 	else
 		ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
 	if (i_size_read(inode) < 0) {
+		brelse(bh);
 		ret = -EFSCORRUPTED;
 		goto bad_inode;
 	}