[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20190206.115241.1549120165262106425.davem@davemloft.net>
Date: Wed, 06 Feb 2019 11:52:41 -0800 (PST)
From: David Miller <davem@...emloft.net>
To: colin.king@...onical.com
Cc: bh74.an@...sung.com, ks.giri@...sung.com, vipul.pandya@...sung.com,
netdev@...r.kernel.org, kernel-janitors@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: sxgbe: fix unintended sign extension
From: Colin King <colin.king@...onical.com>
Date: Wed, 6 Feb 2019 10:25:03 +0000
> From: Colin Ian King <colin.king@...onical.com>
>
> Shifting a u8 by 24 will cause the value to be promoted to an integer. If
> the top bit of the u8 is set then the following conversion to an unsigned
> long will sign extend the value causing the upper 32 bits to be set in
> the result.
We feed this into a writel() which truncates to a 32-bit value, so nothing
bad can happen here.
This is a very canonical way to code up something like this, it works
properly in all situations, and therefore I'd rather not add all of
these fat ugly looking casts.
Thank you.
Powered by blists - more mailing lists