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] [day] [month] [year] [list]
Message-ID: <b28755b0-9104-4295-8cd3-508818445a4b@lunn.ch>
Date: Wed, 5 Feb 2025 18:08:47 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Dimitri Fedrau <dima.fedrau@...il.com>
Cc: "Russell King (Oracle)" <linux@...linux.org.uk>,
	dimitri.fedrau@...bherr.com, Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>, Andrew Davis <afd@...com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Florian Fainelli <f.fainelli@...il.com>, netdev@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3 2/3] net: phy: Add helper for getting tx
 amplitude gain

On Wed, Feb 05, 2025 at 06:22:18AM +0100, Dimitri Fedrau wrote:
> Am Tue, Feb 04, 2025 at 05:54:53PM +0000 schrieb Russell King (Oracle):
> > On Tue, Feb 04, 2025 at 02:09:16PM +0100, Dimitri Fedrau via B4 Relay wrote:
> > >  #if IS_ENABLED(CONFIG_OF_MDIO)
> > > -static int phy_get_int_delay_property(struct device *dev, const char *name)
> > > +static int phy_get_u32_property(struct device *dev, const char *name)
> > >  {
> > >  	s32 int_delay;
> > >  	int ret;
> > > @@ -3108,7 +3108,7 @@ static int phy_get_int_delay_property(struct device *dev, const char *name)
> > >  	return int_delay;
> > 
> > Hmm. You're changing the name of this function from "int" to "u32", yet
> > it still returns "int".
> >
> 
> I just wanted to reuse code for retrieving the u32, I found
> phy_get_int_delay_property and renamed it. But the renaming from "int"
> to "u32" is wrong as you outlined.
> 
> > What range of values are you expecting to be returned by this function?
> > If it's the full range of u32 values, then that overlaps with the error
> > range returned by device_property_read_u32().
> >
> 
> Values are in percent, u8 would already be enough, so it wouldn't
> overlap with the error range.
> 
> > I'm wondering whether it would be better to follow the example set by
> > these device_* functions, and pass a pointer for the value to them, and
> > just have the return value indicating success/failure.
> >
> 
> I would prefer this, but this would mean changes in phy_get_internal_delay
> if we don't want to duplicate code, as phy_get_internal_delay relies on
> phy_get_int_delay_property and we change function parameters of
> phy_get_int_delay_property as you described. I would switch from
> static int phy_get_int_delay_property(struct device *dev, const char *name)
> to
> static int phy_get_u32_property(struct device *dev, const char *name, u32 *val)
> 
> Do you agree ?

This looks O.K. You should also rename the local variable int_delay.

Humm, that function has other issues.

static int phy_get_int_delay_property(struct device *dev, const char *name)
{
	s32 int_delay;
	int ret;

	ret = device_property_read_u32(dev, name, &int_delay);
	if (ret)
		return ret;

	return int_delay;
}

int_delay should really be a u32. if ret is not an error, there should
be a range check to ensure int_long actually fits in an s32, otherwise
-EINVAL, or maybe -ERANGE.

For delays, we never expect too much more than 2000ps, so no valid DT
blob should trigger issues here.

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ