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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5e7c2f9c-bf49-4564-91b3-a639ef1c97d8@lunn.ch>
Date: Tue, 27 Jan 2026 14:50:14 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Daniel Golle <daniel@...rotopia.org>
Cc: Paolo Abeni <pabeni@...hat.com>, Vladimir Oltean <olteanv@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	Simon Horman <horms@...nel.org>, netdev@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	Frank Wunderlich <frankwu@....de>, Chad Monroe <chad@...roe.io>,
	Cezary Wilmanski <cezary.wilmanski@...ran.com>,
	Avinash Jayaraman <ajayaraman@...linear.com>,
	Bing tao Xu <bxu@...linear.com>, Liang Xu <lxu@...linear.com>,
	Juraj Povazanec <jpovazanec@...linear.com>,
	"Fanni (Fang-Yi) Chan" <fchan@...linear.com>,
	"Benny (Ying-Tsan) Weng" <yweng@...linear.com>,
	"Livia M. Rosu" <lrosu@...linear.com>,
	John Crispin <john@...ozen.org>
Subject: Re: [PATCH net-next v8 4/4] net: dsa: add basic initial driver for
 MxL862xx switches

> > > +	/* handle errors returned by the firmware as -EIO
> > > +	 * The firmware is based on Zephyr OS and uses the errors as
> > > +	 * defined in errno.h of Zephyr OS. See
> > > +	 * https://github.com/zephyrproject-rtos/zephyr/blob/v3.7.0/lib/libc/minimal/include/errno.h
> > > +	 */
> > > +	if ((s16)ret < 0) {
> > 
> > The cast is likely not needed above? if `ret` values < S16_MIN are
> > possible this will return such values to the caller without the IO err
> > printk.
> 
> Right, it should rather be
> 
> if (ret > S16_MAX && ret <= U16_MAX)
> 
> to really only catch the range of numbers which are negative 16-bit
> signed values represented as positive 32-bit signed values.
> 
> mxl862xx_reg_read() primarily returns a signed 32-bit integer, as it is
> basically just a wrapper around __mdiodev_c45_read(). Negative values of
> that 32-bit integer mean that the MDIO Clause-45 read has somehow
> failed, ie. it's the error the MDIO bus .read_c45() operation has
> returned.
> 
> In case __mdiodev_c45_read() succeeds it returns the 16-bit value of the
> register read. In this case, those 16-bit should be interpreted as a
> 16-bit signed integer here. A negative value denotes an error returned
> from the firmware running on the switch (see comment above the code).

Rather than these casts, maybe add a helper which takes the unsigned
u16 from the register and returns a signed Zepher error code?

int mxl862xx_to_zephyr_errno(u16 reg)

Just having a name like this makes it clearer what is going on.

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ