Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4854880pxb; Tue, 28 Sep 2021 05:44:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVj46R4hkbiMmf0P8I03cMzFMkZSpXSaDj7vOdWbU6B2rAqIJ7MdtsFh+kAz0Nq3k1ES2F X-Received: by 2002:a17:906:31ca:: with SMTP id f10mr6391048ejf.73.1632833040244; Tue, 28 Sep 2021 05:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632833040; cv=none; d=google.com; s=arc-20160816; b=YXi3uyspOVMY3PlmPMdYz3/bc2LlwQqvJaL9tDGKIDDemL4bzU1Nce4U2W/LINTLak PRLOwx/urqff97ZrIW78ThHPKxni8XGaeZGWZRphDayRFPVvirLZB00qeqxRP7FC1x6E 0ai99OKCwQfIyW9qvmQPRSHUTkTMhd1N7Sx3l+b9UDRynrGz+A0zE9SLyGOXLGe3g+a6 W1dpRx7VNYGw776jrTnV+mKRKGA4PryubnzzVIQyiSpaURVMB+kJ1kTIf0ZYyaPQtxBL yVy0Q72mvOXtAxjRRSxPRcKkG1bs90gFggjajhOoruWpj+rPDv69GQpiHTZciOPAsVyK 45uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2DViiAQTdEoKI2fpopTtP6odKlo9WFvqVxYGHWPH0g4=; b=hKeXaQkEs2iC+8F0dR9mK1SPs3eJgeFdeAGhDVjz4sFe/3RPt70Si1d1zFD/2W5pD6 f2Y76VnI3Yminmj6FhRYilJlGEwtTz8MGpmSIibtHTBQraomEm6K0UXgXWntNtUDWlEG 66jjZEEKeTS5oKvsBl5v3clDrs4ZxqJYEO/iaoVrXw8UTYgnp95ySqtLQJPeM5iK59ee KCz4hpVZMccj0OTNpPSoQgZv/cdva0FIpXxsg8geUfB0SdbuuL37tWgLckJtEqSOpKpo xaGJx0xo/OVyXRrEEuGW1V8yJwENDo6Tpt+LE98WHWZ+Ca/74SmjcwiHmIfaBIXru6Ze rFJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=mK8yiJZQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si24976182ede.102.2021.09.28.05.43.35; Tue, 28 Sep 2021 05:44:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=mK8yiJZQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240669AbhI1Mky (ORCPT + 99 others); Tue, 28 Sep 2021 08:40:54 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:53818 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240526AbhI1Mkw (ORCPT ); Tue, 28 Sep 2021 08:40:52 -0400 Received: from localhost (1.general.cking.uk.vpn [10.172.193.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id B2C0E4030D; Tue, 28 Sep 2021 12:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632832746; bh=2DViiAQTdEoKI2fpopTtP6odKlo9WFvqVxYGHWPH0g4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=mK8yiJZQs8b8HsY3AavAxHYNnvDECP6ov7lnytbU9Sv071sThnwfns6nwyGWGLwwD /txRgug6pG/RoyiCdzpQgHu+ggvQ1KQPwuxZCsHcgIk32/ZCe0Fq8yalKnpGvPyJvV 9qzmBUEetfqaYvGh+GRZ1DG4IS4JJWVWz4Fk64TZbn/bmynf50Dpq8Nb2Zrss9KVrS KDOHmGRvhQVSmvxWvn49y3xyZJBiKQ5TXYDUlt99uzR/QC2ThHYtxfacQLkXO1bymZ cRr/gMjqFUzPi1mMg+C9HrkhGgcfrAdapFKTHxwcbscXWNZPwHQ1UtgZehZSkaKpZ/ kA/ekJG3u9aAw== From: Colin King To: Daniel Palmer , Romain Perier , Alessandro Zummo , Alexandre Belloni , Nobuhiro Iwamatsu , linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] rtc: msc313: Fix unintentional sign extension issue on left shift of a u16 Date: Tue, 28 Sep 2021 13:39:06 +0100 Message-Id: <20210928123906.988813-1-colin.king@canonical.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Shifting the u16 value returned by readw by 16 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 the readw is set then the shifted value will be sign extended and the top 32 bits of the result will be set. Fixes: be7d9c9161b9 ("rtc: Add support for the MSTAR MSC313 RTC") Signed-off-by: Colin Ian King --- drivers/rtc/rtc-msc313.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-msc313.c b/drivers/rtc/rtc-msc313.c index 5f178d29cfd8..7430244ad867 100644 --- a/drivers/rtc/rtc-msc313.c +++ b/drivers/rtc/rtc-msc313.c @@ -53,7 +53,7 @@ static int msc313_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) unsigned long seconds; seconds = readw(priv->rtc_base + REG_RTC_MATCH_VAL_L) - | (readw(priv->rtc_base + REG_RTC_MATCH_VAL_H) << 16); + | ((unsigned long)readw(priv->rtc_base + REG_RTC_MATCH_VAL_H) << 16); rtc_time64_to_tm(seconds, &alarm->time); -- 2.32.0