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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 Nov 2017 15:24:50 +0100
From:   David Sterba <dsterba@...e.cz>
To:     SF Markus Elfring <elfring@...rs.sourceforge.net>
Cc:     linux-btrfs@...r.kernel.org, Chris Mason <clm@...com>,
        David Sterba <dsterba@...e.com>, Josef Bacik <jbacik@...com>,
        linux-fsdevel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] btrfs/volumes: Improve unlocking of a mutex in
 __btrfs_balance()

On Mon, Nov 06, 2017 at 09:04:37AM +0100, SF Markus Elfring wrote:
> 
> * Adjust jump targets so that a call of the function "mutex_unlock"
>   can be better reused for error cases at the end of this function.
> 
> * Replace three calls by goto statements.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
> @@ -3682,7 +3678,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
>  		counting = false;
>  		goto again;
>  	}
> -error:
> +free_path:
>  	btrfs_free_path(path);
>  	if (enospc_errors) {
>  		btrfs_info(fs_info, "%d enospc errors during balance",
> @@ -3692,6 +3688,10 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
>  	}
>  
>  	return ret;
> +
> +unlock:
> +	mutex_unlock(&fs_info->delete_unused_bgs_mutex);
> +	goto free_path;
>  }

This is also an anti-pattern, the label followed by a goto jumping back
to the exit/cleanup block, right at the end of a function. I've sent
some patches in the past to clean that up and don't want to reintroduce
it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ