[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180216235232.GI14177@piout.net>
Date: Sat, 17 Feb 2018 00:52:32 +0100
From: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
To: Colin King <colin.king@...onical.com>
Cc: Alessandro Zummo <a.zummo@...ertech.it>, linux-rtc@...r.kernel.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][V2] rtc: tx4939: avoid unintended sign extension on a 24
bit shift
On 15/02/2018 at 19:36:14 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> The shifting of buf[5] by 24 bits to the left will be promoted to
> a 32 bit signed int and then sign-extended to an unsigned long. If
> the top bit of buf[5] is set then all then all the upper bits sec
> end up as also being set because of the sign-extension. Fix this by
> casting buf[5] to an unsigned long before the shift.
>
> Detected by CoverityScan, CID#1465292 ("Unintended sign extension")
>
> Fixes: 0e1492330cd2 ("rtc: add rtc-tx4939 driver")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
> drivers/rtc/rtc-tx4939.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Applied, thanks.
--
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
Powered by blists - more mailing lists