Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp459430ybl; Tue, 28 Jan 2020 06:18:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxdGz/SGyzVGd65Vr+SMrdQ6g7P6mYpQE7wodnG6doz1ffo98LOJVQ7JFHnVaIbLZ5HLR04 X-Received: by 2002:aca:53c6:: with SMTP id h189mr2966088oib.11.1580221117453; Tue, 28 Jan 2020 06:18:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221117; cv=none; d=google.com; s=arc-20160816; b=fCuoVl7uyHJpaDFz8fbKRObpJQaOeAfHZm9hviAj7xvFzQ46fTS2TuiFGpc3iTKIlM jIVpuGVjEXqInXU4xi8SM3kRVhFGv0uDfOHZyiZQdHsbsWYe3w7CZeWPWcW9v01Mn8iZ OGUwrBmBUJxG2p9WzwRi1VhyVfvikdoKaT+SE6kZZW1Ns4zeX9XbDh2OS7gwn1Vn6jml RMrZdOyOCgk46W/lkhnO1PTN4ooxg/5PusGrBiforBxdzKZIM3VYhJJ1X5kFQ4TQFyFF 6Jg7BAqGPdkl4IzEQTnVCjKhzZCkCLqiwrl3mcw+Up2drqIeahlTRNct2sYhZJKoC1WB SvBg== 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=FV44wtolPkcyl8o4CfQvEGwkQTtJdE64ZmnnnfvIQjM=; b=Omw2p0li2HifULHlRDoXGZP+GiEc+1nNgPlDCu4olGYMLihivbg4f54hTqA+OQS5mR veO33DPZlxOCpv5rKN/8RiHNgLzjVZUAtF6KZif6eBuxvZPIeRkbe8Yp7SRQxhBJE7mQ c4LSIQptAc0kAC/hbBqoXgGq3X+5BcmZcOPFSwyoVPlHX8pgvORfnoVjsEzyrC+vndWN FheAedPEm/hxdWwgLOEKyScZjh9oS5gTLDu5xyd6X2/kVMWlm/1t92JKgIiBZrLcHH1h PQD3vLPyHEgcmu0UA+4/Wcd55/ljXR6Vhukh8LV057NYve3XLdWouCfsUWMpLxaQEaNK lfpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w7Vvuy6s; 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 h7si7679786otm.165.2020.01.28.06.18.25; Tue, 28 Jan 2020 06:18:37 -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=w7Vvuy6s; 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 S1729917AbgA1OR1 (ORCPT + 99 others); Tue, 28 Jan 2020 09:17:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:41104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729977AbgA1ORW (ORCPT ); Tue, 28 Jan 2020 09:17:22 -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 C69402071E; Tue, 28 Jan 2020 14:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221042; bh=nVu7Lc0yiqepNHw5qjG/DjEzlaDyKfhKmT9JqkUZwpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w7Vvuy6scQT6m+/TEusfnFi3x84Q6ugDeL3UWnKDrWzxIo5or4YOn6G+FhVuQvGsH qV8ouEHzf70k8iIe2+QjqMMTf1Xrph8Xtf6SZYTYmaHQ5czaECkxFoExJqmqZfOxfQ PR0I5OGvsYnoaOuvovIQuZquMpuMPv4xXC4Y0od8= 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 064/271] rtc: pm8xxx: fix unintended sign extension Date: Tue, 28 Jan 2020 15:03:33 +0100 Message-Id: <20200128135857.380313453@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 e42280886018c6f77f0a90190f7cba344b0df3e0 ] 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#1309693 ("Unintended sign extension") Fixes: 9a9a54ad7aa2 ("drivers/rtc: add support for Qualcomm PMIC8xxx RTC") Signed-off-by: Colin Ian King Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-pm8xxx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index fac835530671f..a1b4b0ed1f196 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -186,7 +186,8 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) } } - secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); + secs = value[0] | (value[1] << 8) | (value[2] << 16) | + ((unsigned long)value[3] << 24); rtc_time_to_tm(secs, tm); @@ -267,7 +268,8 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) return rc; } - secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); + secs = value[0] | (value[1] << 8) | (value[2] << 16) | + ((unsigned long)value[3] << 24); rtc_time_to_tm(secs, &alarm->time); -- 2.20.1