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: <ada4p4mm6iy.fsf@cisco.com>
Date:	Thu, 11 Sep 2008 19:39:49 -0700
From:	Roland Dreier <rdreier@...co.com>
To:	Larry Finger <Larry.Finger@...inger.net>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	wireless <linux-wireless@...r.kernel.org>
Subject: Re: I need help with a sparse warning

 > In file drivers/net/wireless/p54/p54common.c, the statement
 > 
 >        priv->rx_mtu = (size_t) le16_to_cpu((__le16)bootrec->data[10]);

[I don't see this code in Linus's tree]

 > 
 > generates the sparse warning
 > 
 > .../p54common.c:185:29: warning: cast to restricted __le16
 > 
 > where bootrec->data is u32, and priv->rx_mtu is u16.
 > 
 > What should be done to eliminate this warning?

the code in question looks buggy to me.  Since bootrec->data[10] is u32,
casting it to a 16-bit type is going to take a different 2 bytes out of
the 4 bytes depending on the endianness of the system the driver is
built for.  And I assume you are parsing some fixed-layout thing that
the firmware is giving you or something like that.

I would guess you want something like:

	priv->rx_mtu = le16_to_cpu(((__force __le16 *) bootrec->data)[20]);

(__force is what shuts up sparse, and as far as I can see, the size_t
cast is useless, since the result will be promoted anyway)

 - R.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ