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, 16 Aug 2023 10:51:41 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Andrew Lunn <andrew@...n.ch>
Cc: Justin Stitt <justinstitt@...gle.com>,
	Iyappan Subramanian <iyappan@...amperecomputing.com>,
	Keyur Chudgar <keyur@...amperecomputing.com>,
	Quan Nguyen <quan@...amperecomputing.com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Nathan Chancellor <nathan@...nel.org>,
	Nick Desaulniers <ndesaulniers@...gle.com>,
	Tom Rix <trix@...hat.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] net: mdio: fix -Wvoid-pointer-to-enum-cast warning

On Tue, Aug 15, 2023 at 10:41:39PM +0200, Andrew Lunn wrote:
> On Tue, Aug 15, 2023 at 08:35:59PM +0000, Justin Stitt wrote:
> > When building with clang 18 I see the following warning:
> > |       drivers/net/mdio/mdio-xgene.c:338:13: warning: cast to smaller integer
> > |               type 'enum xgene_mdio_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
> > |         338 |                 mdio_id = (enum xgene_mdio_id)of_id->data;
> > 
> > This is due to the fact that `of_id->data` is a void* while `enum
> > xgene_mdio_id` has the size of an int. This leads to truncation and
> > possible data loss.
> > 
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1910
> > Reported-by: Nathan Chancellor <nathan@...nel.org>
> > Signed-off-by: Justin Stitt <justinstitt@...gle.com>
> 
> Reviewed-by: Andrew Lunn <andrew@...n.ch>

I wonder whether it would be better to use device_get_match_data()
here? The whole of_match_device()...acpi_match_device() dance could
become:

+	mdio_id = (uintptr_t)device_get_match_data(&pdev->dev);
	if (!mdio_id)
		return -ENODEV;

It's probably something for a follow-up patch though.

Reviewed-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ