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]
Message-ID: <c6a3df74-257f-4e29-a8f4-e26a40213201@lunn.ch>
Date: Thu, 27 Jun 2024 02:00:35 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: Florian Fainelli <f.fainelli@...il.com>,
	Vladimir Oltean <olteanv@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
	Marek BehĂșn <kabel@...nel.org>,
	Jiasheng Jiang <jiasheng@...as.ac.cn>,
	"justinstitt@...gle.com" <justinstitt@...gle.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [net-next RFC PATCH 2/2] net: dsa: qca: qca8k: convert to guard
 API

On Thu, Jun 27, 2024 at 01:02:32AM +0200, Christian Marangi wrote:
> Convert every entry of mutex_lock/unlock() to guard API.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
> ---
>  drivers/net/dsa/qca/qca8k-8xxx.c   |  99 +++++++----------------
>  drivers/net/dsa/qca/qca8k-common.c | 122 ++++++++++++-----------------
>  2 files changed, 81 insertions(+), 140 deletions(-)
> 
> diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
> index b3c27cf538e8..2d9526b696f2 100644
> --- a/drivers/net/dsa/qca/qca8k-8xxx.c
> +++ b/drivers/net/dsa/qca/qca8k-8xxx.c
> @@ -6,6 +6,7 @@
>   * Copyright (c) 2016 John Crispin <john@...ozen.org>
>   */
>  
> +#include <linux/cleanup.h>
>  #include <linux/module.h>
>  #include <linux/phy.h>
>  #include <linux/netdevice.h>
> @@ -321,12 +322,11 @@ static int qca8k_read_eth(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
>  	if (!skb)
>  		return -ENOMEM;
>  
> -	mutex_lock(&mgmt_eth_data->mutex);
> +	guard(mutex)(&mgmt_eth_data->mutex);
>  
>  	/* Check if the mgmt_conduit if is operational */
>  	if (!priv->mgmt_conduit) {
>  		kfree_skb(skb);
> -		mutex_unlock(&mgmt_eth_data->mutex);
>  		return -EINVAL;

Sorry, but NACK.

There are two issues here.

1) guard() is very magical, the opposite of C which is explicit.  We
   discussed that, and think scoped_guard is O.K, since it is more C
   like.

2) We don't want scope_guard or guard introduced in existing code, at
   least not for the moment, because it seems like it is going to make
   back porting patches for stable harder/more error prone.

We do however see that these mechanisms are useful, could solve
problems, so its O.K. to use scoped_guard in new code. In a few years
we will see how things have actually worked out, and reevaluate our
position and maybe allow scoped_guard to be added to existing code.

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ