Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp460470ybl; Tue, 28 Jan 2020 06:19:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwlnuUw1W3VuL0MhQVdabpS7nzQk9qnkI/lANcZDWCKJdtebickkmRriMgv1XdWnHpSHm0K X-Received: by 2002:a9d:7083:: with SMTP id l3mr9013790otj.193.1580221168048; Tue, 28 Jan 2020 06:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221168; cv=none; d=google.com; s=arc-20160816; b=SuKDiQv4P4ukSwPLRDxaq0+OlwFveI54KwP+Aw1CwXy0QPhL0RzK8/noCP2TEvTa1/ X9+NS9t6yCTYE/zhDL5i6+PUd1K7hK89gco0YMJoGPoM8sUPohhJeufd9mhTIpMangsU oof40Iwou+QdXR7ylsb1KM5HAAz8x6kwAXz2oZu9Bp/rVsSauRXIsrJWv7Q/cklT24qY XBufrVT0FXLauTxEBgb6NGBSb4kXsDZqPUET8DMr9cZdlE7L1639Noc/bf64YFpVn+Cl +S9vs/WFryPCgiu+tKtEILpM7LEaT5prx8RYfc6qxMGZjEk7ZyskuPYJLkMfxxHagvBV UxXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6/+lLSduJu4zE4HmIscqd2JOwp012iUIeb2wq8i7+mA=; b=XMgMxXZ17er03QkGVnmEA1V3wadFmUBBQsLq4yv8xQl1y72th9pcjvvu78Z768xq7/ oH21MpHAw6YSD8UhM1mC3qkbDatDu8Spip8F0oeZW/iTwPz+np6eMv5I38sv/DsOYJOq 50sDOC0l/7atbbqu4ncijpOqvBD7ffqLl2tv9AV2d7V477Js1AzjMXFcp42DlJNXL34j PnjNjMTI4penwR0VQ30KxN6+yOe+cHyN/R0KUtqfSWjhN73MQNulyI+noP6E/t98ZiOM xdOU2fIhOIgqMyFR/BFuuZb8AdtBLLnE0Px3PMWOamS0jz76vMpcBccWwvCUaJCy3P36 HUQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aWwX8EmX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si8274938otq.112.2020.01.28.06.19.15; Tue, 28 Jan 2020 06:19:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aWwX8EmX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728204AbgA1ORM (ORCPT + 99 others); Tue, 28 Jan 2020 09:17:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:40826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729986AbgA1ORK (ORCPT ); Tue, 28 Jan 2020 09:17:10 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DFF62071E; Tue, 28 Jan 2020 14:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221030; bh=yTxA6aDFcdfjGIzf+6Js8e99cEdZLEXqW9hUaiwDaNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aWwX8EmXoPdR6CcjBciWRWI3lGHN1LZOyT3iWpldR7n+1rMwDO7yhNOfV0QNrLx41 0KZcbCm21xWz8dfb8t6meNrE/cPEAubjLXdTua2YURUzvIKuIdeVMRuiJtrI6K8vrl KCgs2bld+PdyRY5X0W0ibq08aK6YOk+7NawwIVKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.9 059/271] rtc: ds1672: fix unintended sign extension Date: Tue, 28 Jan 2020 15:03:28 +0100 Message-Id: <20200128135857.028216999@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit f0c04c276739ed8acbb41b4868e942a55b128dca ] 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. Fix this by casting the u8 value to an unsigned long before the shift. Detected by CoverityScan, CID#138801 ("Unintended sign extension") Fixes: edf1aaa31fc5 ("[PATCH] RTC subsystem: DS1672 driver") Signed-off-by: Colin Ian King Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-ds1672.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 5c18ac7394c42..c911f2db0af5e 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c @@ -58,7 +58,8 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) "%s: raw read data - counters=%02x,%02x,%02x,%02x\n", __func__, buf[0], buf[1], buf[2], buf[3]); - time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; + time = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | + (buf[1] << 8) | buf[0]; rtc_time_to_tm(time, tm); -- 2.20.1