lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 31 May 2019 15:46:54 -0600
From:   Andreas Dilger <adilger@...ger.ca>
To:     Pavel Tikhomirov <ptikhomirov@...tuozzo.com>
Cc:     Theodore Ts'o <tytso@....edu>,
        linux-ext4 <linux-ext4@...r.kernel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ext4: remove unnecessary gotos in ext4_xattr_set_entry

On May 31, 2019, at 6:10 AM, Pavel Tikhomirov <ptikhomirov@...tuozzo.com> wrote:
> 
> In the "out" label we only iput old/new_ea_inode-s, in all these places
> these variables are always NULL so there is no point in goto to "out".
> 
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@...tuozzo.com>

I'm not a fan of changes like this, since it adds potential complexity/bugs
if the error handling path is changed in the future.  That is one of the major
benefits of the "goto out_*" model of error handling is that you only need to
add one new label to the end of the function when some new state is added that
needs to be cleaned up, compared to having to check each individual error to
see if something needs to be cleaned up.

Cheers, Andreas

> ---
> fs/ext4/xattr.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 491f9ee4040e..ac2ddd4446b3 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1601,8 +1601,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
> 		next = EXT4_XATTR_NEXT(last);
> 		if ((void *)next >= s->end) {
> 			EXT4_ERROR_INODE(inode, "corrupted xattr entries");
> -			ret = -EFSCORRUPTED;
> -			goto out;
> +			return -EFSCORRUPTED;
> 		}
> 		if (!last->e_value_inum && last->e_value_size) {
> 			size_t offs = le16_to_cpu(last->e_value_offs);
> @@ -1620,8 +1619,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
> 			free += EXT4_XATTR_LEN(name_len) + old_size;
> 
> 		if (free < EXT4_XATTR_LEN(name_len) + new_size) {
> -			ret = -ENOSPC;
> -			goto out;
> +			return -ENOSPC;
> 		}
> 
> 		/*
> @@ -1634,8 +1632,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
> 		    new_size && is_block &&
> 		    (min_offs + old_size - new_size) <
> 					EXT4_XATTR_BLOCK_RESERVE(inode)) {
> -			ret = -ENOSPC;
> -			goto out;
> +			return -ENOSPC;
> 		}
> 	}
> 
> --
> 2.20.1
> 


Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists