From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8636C35273 for ; Mon, 7 Feb 2022 11:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352158AbiBGLLx (ORCPT ); Mon, 7 Feb 2022 06:11:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238446AbiBGLKM (ORCPT ); Mon, 7 Feb 2022 06:10:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B04C043188; Mon, 7 Feb 2022 03:10:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8271A613FB; Mon, 7 Feb 2022 11:10:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35863C004E1; Mon, 7 Feb 2022 11:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232211; bh=VmPwG06BoYxolGXfIBhJmLsdJiUdT/22gIzJPpO0ABE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i7Z/k7G4zjJRI0Bq2/HHoFTOTWyP+Z1nCkCH6Rh2EnzDnDmAEw6k2rwtf7rLw5FGZ /0D2D7K/8B5CUMtkRFH9vKvW1ZC2QVCiRc22UoestOom+sj90X5Cv/xyw8wfzdHk0G n3WjU+3f5gl5HYKVDuf9n1aaNd7iCeEK+cPuJEs4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riwen Lu , Eric Wong , =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Alexandre Belloni Subject: [PATCH 4.9 45/48] rtc: cmos: Evaluate century appropriate Date: Mon, 7 Feb 2022 12:06:18 +0100 Message-Id: <20220207103753.795773960@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103752.341184175@linuxfoundation.org> References: <20220207103752.341184175@linuxfoundation.org> User-Agent: quilt/0.66 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: Riwen Lu commit ff164ae39b82ee483b24579c8e22a13a8ce5bd04 upstream. There's limiting the year to 2069. When setting the rtc year to 2070, reading it returns 1970. Evaluate century starting from 19 to count the correct year. $ sudo date -s 20700106 Mon 06 Jan 2070 12:00:00 AM CST $ sudo hwclock -w $ sudo hwclock -r 1970-01-06 12:00:49.604968+08:00 Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte") Signed-off-by: Riwen Lu Acked-by: Eric Wong Reviewed-by: Mateusz Jończyk Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn Signed-off-by: Mateusz Jończyk # preparation for stable Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-mc146818-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -82,7 +82,7 @@ unsigned int mc146818_get_time(struct rt time->tm_year += real_year - 72; #endif - if (century > 20) + if (century > 19) time->tm_year += (century - 19) * 100; /*