Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp182492lqp; Tue, 11 Jun 2024 00:44:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWc+RqPcBUJ0sDXNqAoHwGb+2FIoy3X4coZ6lHMLBwclUaoOz+fAUUZ2nX/lBOgG+4jdcmQlkaUs2e4pv4rJ/23bMPrArmFd50+Wp6gVA== X-Google-Smtp-Source: AGHT+IHL+Sf6I54gGtNDbb9/Yhgcb3ho57+tzSsQ4UZzrGkN0QJinIYwUJTqaFt8htnsnAlWpshR X-Received: by 2002:a05:6a00:2ea2:b0:705:995c:3e30 with SMTP id d2e1a72fcca58-705a85c2c9emr2917614b3a.17.1718091883494; Tue, 11 Jun 2024 00:44:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718091883; cv=pass; d=google.com; s=arc-20160816; b=Zu6CtFhXmsCCYlQHDVU83cY+gls4j3/fkyv2qthyMBEv04Sba+MqYrhXlPjGxEtT8O Ng8QOJrU415lcokTVvryR76ySI9w3R1xFv0ncurDJJ50bqQfp5X7KV9/mmc1IR9smusA dqi4z8tOYqtJYQLeIhdTlAtuVMBedEgudalhlxh08JftNrEdnl6HhXlZ8+7NpUz4zRL+ GInAFF3wF3fN6PKHWPw/dJD5w81A27Bz9B+SsNNBWcbydxRs4FWG9l/+uJERmxRWkcb2 iFf7HYNhX8UusZ6yCEORGjcslbapBJEupEfsY9Jkpm6LAqAxGmPERu+c40amrx4livar bmjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Lyr4vKbJDlBYGx7GCBBGE5ECzYDxemWMfM7u2PghLS8=; fh=CPOLqFnQfoZ/CyjPi6zabx9zHfUJFKEpEOQnrA/P06w=; b=rTuWH8e9BLify/TN234Pt7dPvzeK3I4idmwC/iD0IyKb/afICquZBpJuY+s4ZiBe67 34JjzpTzjLcHExhY687Y0u7Hgd23cxze+NbbvSawcnLLtTdAJZqzw1+q39Z8VakLigbv y3OfrEvOUkKEetJJk3JAqc2ZlKwpQ56A5K+4HVJHN0EfKIMH+I0CE8JJ/U0Os/leP05T pCY8Haa212+2V1BtZkW0OQmrL4KRKtDt6G/PIzkAD9WOIUSOf8WJ2tJfMtt5WOqk2OPm /uDRe+EO+Gfbjbr3Kn6m+P+n6JbyguAmu21pLLQrUsvvj/3uHCTXsIHv9JB4jLNRh4MK yDrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@prolan.hu header.s=mail header.b=VWxMbzur; arc=pass (i=1 spf=pass spfdomain=prolan.hu dkim=pass dkdomain=prolan.hu dmarc=pass fromdomain=prolan.hu); spf=pass (google.com: domain of linux-kernel+bounces-209373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=prolan.hu Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2895b247si6065648a12.627.2024.06.11.00.44.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 00:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@prolan.hu header.s=mail header.b=VWxMbzur; arc=pass (i=1 spf=pass spfdomain=prolan.hu dkim=pass dkdomain=prolan.hu dmarc=pass fromdomain=prolan.hu); spf=pass (google.com: domain of linux-kernel+bounces-209373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=prolan.hu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 64AD028BDC9 for ; Tue, 11 Jun 2024 07:24:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7069172773; Tue, 11 Jun 2024 07:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="VWxMbzur" Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 239B813D8BA; Tue, 11 Jun 2024 07:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718090679; cv=none; b=bEwCQsxylAvkeC2QFYCJj53wO8EH3jKlIpv6Dt7rgwiGNipOAfut+ONBd1Mxq5XbMqwh/0qbC0/D4dclFxYc2wjNKwF2wjJ788S40nSC3AO08to6DkKlBrII0i13q/uHsAEWd4AULmQXPfWruBEpux6qymNW7u3eZNL8XPOJ/l0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718090679; c=relaxed/simple; bh=/BViwiv7ODDGxwqmgG1UcvqUTvS9SkMogPTYvFA1l/o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NpOfpI5ABbsMTF9+y8w+3CrFNPyqS1m5YtPfn6IXQi14arfp74z7flKrow68cJGS03Fn/YMlDkm2KAaANz40TL+7xIPAs4QrXk/Yhu2biVcvZkntpU6HCSOzQEZcokutza5Ig+Usv7QQLx9tbu2GkK2CJrCymTbfNJYdA3XByss= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=VWxMbzur; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 072E8A0A2C; Tue, 11 Jun 2024 09:24:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=Lyr4vKbJDlBYGx7GCBBG E5ECzYDxemWMfM7u2PghLS8=; b=VWxMbzurSef2hfVcbJaRiXq1SAMn+Kma44iI u+MCq2a7ztINQojHBxYyRkWi5Q5YKljbQhs1QiXuc/ceiQDdtcwg9LRndK2FOh+N xjhTBDous4DdKkKXjC65TsP7CcX8gLlj6cMEP9x4qPfj7gikpOaV1S2+mXNIbd20 HTt4qUwUf41KfuWoDUk9398p6rMz+taNcV5nnGRei6tXRBZsD+8lTxP+1Kfoioqg VY8KATsEsVfZYVng+FhVtaBNRe7+ypMaZ5HFoKvK8G5CFkBH8uzBwrVZzw7aArrB LKzgFJ8lv6dbVp0JW5OGWv1I1IcQLwaKjQCn1DGHHEZZypTACMD6dwMuUQCfbkGL DBwoYxHC0kClDIxan2WxjXjOaOKHODqGJkjvs3qfnaiygMYOCIQWa5ZWl83K3lLQ SuoXkSb47Glv1uG2iuln0gkyo1ZF6nabyO9HRlWSg8yTOPWNQgt5yB+wmBTeKA3u I4CoA1rY6cDOAiF206M/tj+2yhmLSyjqjRytanbTUtWUDgaDpKiWokgjNndTgQY3 anRuafDg1YO8lXLQT5uOMWXyV8//1Gbwb8GJ0MGgJupthrNF/rIj/cSSloHW6f8x HVmxbA63YXWdhHYSwFUlyYjnh3bCNnETqSkcwXPignN6tFNMhgp8VsSpxoHwexkx 4kfnyuw= From: =?UTF-8?q?Cs=C3=B3k=C3=A1s=2C=20Bence?= To: , CC: =?UTF-8?q?Cs=C3=B3k=C3=A1s=2C=20Bence?= , =?UTF-8?q?Szentendrei=2C=20Tam=C3=A1s?= , Alexandre Belloni Subject: [PATCH v2 2/2] rtc: ds1307: Clamp year to valid BCD (0-99) in `set_time()` Date: Tue, 11 Jun 2024 09:24:09 +0200 Message-ID: <20240611072411.671600-2-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.45.2.437.gf7de8c0566 In-Reply-To: <20240611072411.671600-1-csokas.bence@prolan.hu> References: <20240611072411.671600-1-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1718090673;VERSION=7972;MC=1998882007;ID=507904;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29916D3B54627C61 `tm_year` may go up to 299 if the device supports the century bit. Therefore, subtracting may not give us a valid 2-digit number, but modulo does. Co-developed-by: Szentendrei, Tamás Signed-off-by: Szentendrei, Tamás Signed-off-by: Csókás, Bence --- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index bdb7b201a160..872e0b679be4 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -359,7 +359,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) regs[DS1307_REG_MONTH] = bin2bcd(t->tm_mon + 1); /* assume 20YY not 19YY */ - tmp = t->tm_year - 100; + tmp = t->tm_year % 100; regs[DS1307_REG_YEAR] = bin2bcd(tmp); if (chip->century_enable_bit) -- 2.34.1