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:   Wed, 5 May 2021 02:51:43 +0200
From:   Ansuel Smith <ansuelsmth@...il.com>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     Florian Fainelli <f.fainelli@...il.com>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Russell King <linux@...linux.org.uk>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH net-next v3 07/20] net: dsa: qca8k: handle error with
 qca8k_rmw operation

On Wed, May 05, 2021 at 02:46:23AM +0200, Andrew Lunn wrote:
> > -static void
> > +static int
> >  qca8k_reg_set(struct qca8k_priv *priv, u32 reg, u32 val)
> >  {
> > -	qca8k_rmw(priv, reg, 0, val);
> > +	int ret;
> > +
> > +	ret = qca8k_rmw(priv, reg, 0, val);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	return 0;
> 
> Maybe return qca8k_rmw(priv, reg, 0, val); ??
> 
> > -static void
> > +static int
> >  qca8k_reg_clear(struct qca8k_priv *priv, u32 reg, u32 val)
> >  {
> > -	qca8k_rmw(priv, reg, val, 0);
> > +	int ret;
> > +
> > +	ret = qca8k_rmw(priv, reg, val, 0);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	return 0;
> >  }
> 
> Maybe return qca8k_rmw(priv, reg, val, 0);
> 
> > @@ -1249,17 +1280,20 @@ qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br)
> >  		/* Add this port to the portvlan mask of the other ports
> >  		 * in the bridge
> >  		 */
> > -		qca8k_reg_set(priv,
> > -			      QCA8K_PORT_LOOKUP_CTRL(i),
> > -			      BIT(port));
> > +		ret = qca8k_reg_set(priv,
> > +				    QCA8K_PORT_LOOKUP_CTRL(i),
> > +				    BIT(port));
> > +		if (ret)
> > +			return ret;
> >  		if (i != port)
> >  			port_mask |= BIT(i);
> >  	}
> > +
> >  	/* Add all other ports to this ports portvlan mask */
> > -	qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> > -		  QCA8K_PORT_LOOKUP_MEMBER, port_mask);
> > +	ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> > +			QCA8K_PORT_LOOKUP_MEMBER, port_mask);
> >  
> > -	return 0;
> > +	return ret < 0 ? ret : 0;
> 
> Can this is simplified to 
> 
> 	return  = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> 			    QCA8K_PORT_LOOKUP_MEMBER, port_mask);
> 
> > @@ -1396,18 +1430,19 @@ qca8k_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
> >  			  struct netlink_ext_ack *extack)
> >  {
> >  	struct qca8k_priv *priv = ds->priv;
> > +	int ret;
> >  
> >  	if (vlan_filtering) {
> > -		qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> > -			  QCA8K_PORT_LOOKUP_VLAN_MODE,
> > -			  QCA8K_PORT_LOOKUP_VLAN_MODE_SECURE);
> > +		ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> > +				QCA8K_PORT_LOOKUP_VLAN_MODE,
> > +				QCA8K_PORT_LOOKUP_VLAN_MODE_SECURE);
> >  	} else {
> > -		qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> > -			  QCA8K_PORT_LOOKUP_VLAN_MODE,
> > -			  QCA8K_PORT_LOOKUP_VLAN_MODE_NONE);
> > +		ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> > +				QCA8K_PORT_LOOKUP_VLAN_MODE,
> > +				QCA8K_PORT_LOOKUP_VLAN_MODE_NONE);
> >  	}
> >  
> > -	return 0;
> > +	return ret < 0 ? ret : 0;
> 
> What does qca8k_rmw() actually return?
>
>      Andrew

qca8k_rmw in the original code returns the value read from the reg and
modified. So this is why all the strange checks. The idea is to not
change the original return values of the users so I check if every return
value is negative and return 0 in all the other cases.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ