From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751134AbeBPXwf (ORCPT ); Fri, 16 Feb 2018 18:52:35 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:35775 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750934AbeBPXwe (ORCPT ); Fri, 16 Feb 2018 18:52:34 -0500 Date: Sat, 17 Feb 2018 00:52:32 +0100 From: Alexandre Belloni To: Colin King Cc: Alessandro Zummo , linux-rtc@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][V2] rtc: tx4939: avoid unintended sign extension on a 24 bit shift Message-ID: <20180216235232.GI14177@piout.net> References: <20180215193614.28684-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180215193614.28684-1-colin.king@canonical.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/02/2018 at 19:36:14 +0000, Colin King wrote: > From: Colin Ian King > > 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 > --- > 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