Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1069648pxa; Wed, 12 Aug 2020 22:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNomlAgRxybD0tFXJFKLReRZePqQUTgbKIOz1lSHpTJlvyk4SXELt+31HTvYlFyymKnaSd X-Received: by 2002:a17:906:9392:: with SMTP id l18mr3171386ejx.357.1597297532708; Wed, 12 Aug 2020 22:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597297532; cv=none; d=google.com; s=arc-20160816; b=JKMVlTYYeCbqTS3rDhkSXNjyjr/0TqjGBCiMEsJJ+7G8HDeFC1lmjwcsprWmOsq9Go p9AvbKXelSYv912ZXBA4ZieRsnmiqFjaeIWUAPIbA1jxoQ9KzhuCaSfpTskF7j5EdpIk WhdW7TOCMFaN51Zl/4oxA/NgDEfC/N5uB2chFDNoQ9ZeACvJhSrrdh8ABpOX6plTsvJ5 EOAA7sxHc3joGcuHxLWU4NM3hSX2eMlaXIudPMVcJfRKerxtRhJ1JGZ2M3AJyym8JKBX BZaVitq7FnTeD2ulhmi30TwVTUhGmY/xRAWC1oGsZSDuAqpWhW5kr6MGmfnJmvFNC1Xn i5dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=K4z6h/ZBrq50C0ovmsW4dSKeXLB4WwD8TYiSUyA2qdo=; b=rGpquelsr9X0ZHbtjx4K6jixXmkIb6a/oaFXQDh35EDAYj/ZzUsLPk5nYzAnnSjakB eI4QCTxC7at4jPY56LmpibdOY2tfr9Fjl5vZCk/+467XiEYZ+BQpsJOvgz9bVi1+ZdhW Pbs5+QtEv2iVjI6XOil2+Z2UlcohX2mPv/749cwfKDGk+iK4oRjYC8UwzKNLYf9odg6y 7GangaOsNwJicqvIKR/R/DsEp15+HgSBDVVbDKXIxKXaDBVQaYeMHW1UGqGRnO7u5IjC qO3MAUbSQiVjkOTMxREEjh9l7fPnCIvBWzgk2jRhyfT6JQZWDe9wFPXvN+2P9g0IiBTM gwGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UJ7YhnJg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si2664136edx.39.2020.08.12.22.45.09; Wed, 12 Aug 2020 22:45:32 -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=@google.com header.s=20161025 header.b=UJ7YhnJg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbgHMFmH (ORCPT + 99 others); Thu, 13 Aug 2020 01:42:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbgHMFmG (ORCPT ); Thu, 13 Aug 2020 01:42:06 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62573C061383 for ; Wed, 12 Aug 2020 22:42:06 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id a14so5405300ybm.13 for ; Wed, 12 Aug 2020 22:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=K4z6h/ZBrq50C0ovmsW4dSKeXLB4WwD8TYiSUyA2qdo=; b=UJ7YhnJgMIiaMtKnMB6qOrejUG2dFZeUxZ46/HNjBls+FfU7g16lyFv5vCUl+VFSmu zaYXZ9vjWg3ojYt5AiYLtEzUlxhjnfxZRLsmRXEzitMwn7mta+KmSo0L3X36xtXin0Hn +sSXlQMxbQNUdHpi6dO4S3/HDpA4VJcLat8ugbW7I5XA1uIp9u3Y86JAmvGzkcdGvKPq h5abmk9/bZJ2LgabX14evoEtBpL33Nzp/wl/5Q17yAjVs8PA2kDyAsfqdl0nKsSkhhcN DvI0UUR/Z9EoFnddTU8iuuQO3PH5ESGqPdkIBhT4x1/xMcUR3y7mkiZ6BdYvUg/F4039 WA5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=K4z6h/ZBrq50C0ovmsW4dSKeXLB4WwD8TYiSUyA2qdo=; b=j28MwGaWUeiVx5Kk4acfJFHBwsxwleC8VBKCGOhhw0CFYGEcvOa1HRvACpmvBWntXr uixDc/Hz/wChad5lXwQ1fr/8lJv8lQPk8S8QLvPlw/ElwNHwUTX7yf3enK3+5jNNbFU3 KleCUGsg7b7aYweKEP6f1TWbYHvSVFXgwS7TkPNRL9/h1zYU+xfdYQzti+vLj4JgLY3I nbz4ccrSAJHrX5tyS4OVjlQD+l8KFZP6W82/QO7HzwmoA9Ki1ojdp25GGDCpJttM4P6C jdr7nlQmAPOHBfUBoGQCgsQ2EpYBr38XFfUegNVjtvuaqC5IT0+7Uvag1FKIjZkMY5d1 N/Ug== X-Gm-Message-State: AOAM531ckXncMFKykqNS9r4u6DooYviwxLkobShPqBseOoE8E2UpEXvN RKmf8Ahjss487QiDksJ8HrZSqrnOa4Hvx3AFOKUMuXtnbR+8dBPxPlln0tRhVaLfDrvBknJx0Wl wVQCRAIjp9X676leH23LgvqmIPVW0q4hHwsv9bnpBg71Ag+xCdLhZ8VGXAsJ+g82UGpIp9wMm0u 1aCnF9 X-Received: by 2002:a25:3754:: with SMTP id e81mr4501384yba.22.1597297325101; Wed, 12 Aug 2020 22:42:05 -0700 (PDT) Date: Thu, 13 Aug 2020 15:41:34 +1000 Message-Id: <20200813154020.1.Iaf7638a2f2a87ff68d85fcb8dec615e41340c97f@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH] rtc: cmos: initialize rtc time when reading alarm From: Victor Ding To: LKML Cc: Victor Ding , Alessandro Zummo , Alexandre Belloni , linux-rtc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cmos_read_alarm() may leave certain fields of a struct rtc_time untouched; therefore, these fields contain garbage if not properly initialized, leading to inconsistent values when converting into time64_t. This patch to set all fields of a struct rtc_time to -1 before calling cmos_read_alarm(). Signed-off-by: Victor Ding --- drivers/rtc/rtc-cmos.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index bcc96ab7793f..c99af567780d 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -1006,6 +1006,7 @@ static int cmos_suspend(struct device *dev) enable_irq_wake(cmos->irq); } + memset(&cmos->saved_wkalrm.time, -1, sizeof(struct rtc_time)); cmos_read_alarm(dev, &cmos->saved_wkalrm); dev_dbg(dev, "suspend%s, ctrl %02x\n", @@ -1054,6 +1055,7 @@ static void cmos_check_wkalrm(struct device *dev) return; } + memset(¤t_alarm.time, -1, sizeof(struct rtc_time)); cmos_read_alarm(dev, ¤t_alarm); t_current_expires = rtc_tm_to_time64(¤t_alarm.time); t_saved_expires = rtc_tm_to_time64(&cmos->saved_wkalrm.time); -- 2.28.0.236.gb10cc79966-goog