Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1019438pxb; Wed, 6 Apr 2022 06:53:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOoNcCfIOGiFoPTwTtekB5xkejb5EZiimxn5MZhp30VyGIBNw08i+kouP6m0mk72cXfEXQ X-Received: by 2002:a63:d342:0:b0:381:fd6f:4792 with SMTP id u2-20020a63d342000000b00381fd6f4792mr7103512pgi.101.1649253210817; Wed, 06 Apr 2022 06:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649253210; cv=none; d=google.com; s=arc-20160816; b=L4fqcRe08BpuLtSv58QHmVK0bjzrAwUBqoJ7f2ijhWtu7760q1xNptw1uF2M+inpBl oh6gCAzjlXqxDUdO12Y8448bT+XVZhMreCjHk+O1XuvdR5j6VP7GfliCBUAalDGfpFhl h0Rv2mUKr/Rf2XfQwiXB9jyzELoi+/5HgSUoHJ4KfQTBaV6TA34xjg6o3LGnJNjAO7xR StOXSUVKx6ZH1yxeb4x9/BstjlXye+R5BSB/uylWpTGLL9laaVZTII8/F5xX79NdAPPp q3rqqwWbYdXw6MZPoSOPaHmBuA4D/Mq19CLaTkMXllXbC58bZZKAud4OnB2fVrrps9Se /T6Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BTBIaeDGqEdr3m4dsRojmcOh1DZLn6kNYkBa3gpY/qQ=; b=doMwKxZDXxa5Cuq23uTlTNPSLinafUFY+D4yvaT9wavY3hb8QwXd9mUb/3hlKrTDpH CkcobS5+NoOvhvvcrx87kJUpUlOMbHpwKYcV2YuwNfoT57WLKvmO47b1EFZKkRPba77D VUzIPMipUuKnut90xXJv34i+SMUaxoesNpwTfIEFE9PnHokXtJ1xP/MkJZlWkrHDemOt s/4pl3393p9BU6tIVPnxMR7BvlCbyQhDLv0Uu7KoeUuCIHmx5kwiznvlaRhcaIHAqJHF u+JTO1VenoLrU7QYHgMEngt86RDPaa4UCq/k2ElbLpZS0Vduz0iOUUXjzNsET0tMEWm3 ygWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MzYnBk/7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d20-20020aa797b4000000b004fa3a8dfff8si14589843pfq.175.2022.04.06.06.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:53:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MzYnBk/7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08460674238; Wed, 6 Apr 2022 05:36:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237299AbiDEWGF (ORCPT + 99 others); Tue, 5 Apr 2022 18:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354022AbiDEKKs (ORCPT ); Tue, 5 Apr 2022 06:10:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE354F9ED; Tue, 5 Apr 2022 02:56:44 -0700 (PDT) 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 C8A056157A; Tue, 5 Apr 2022 09:56:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFB54C385A2; Tue, 5 Apr 2022 09:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152603; bh=BBGt+GgEpJktuRha/6PB6GGM4VbMgSz88KLc5ZHLTZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MzYnBk/7/ZLzjC31R+akUzHNpAUiyrWJPSJSyqrHQEW4+Wrkcd1c9MSx/oL5ECemi d8CdybSWZwsea8A/HDIUJtr+fv6HZGr7xhgtorp6Ie2/nqVd0Ew98ndn1tPsiEbzrV 4e8WWiTaq7z3sns460GBvtviCEj2vYItYu5uF4/Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Alexandre Belloni Subject: [PATCH 5.15 837/913] rtc: check if __rtc_read_time was successful Date: Tue, 5 Apr 2022 09:31:39 +0200 Message-Id: <20220405070404.919159950@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix commit 915593a7a663b2ad08b895a5f3ba8b19d89d4ebf upstream. Clang static analysis reports this issue interface.c:810:8: warning: Passed-by-value struct argument contains uninitialized data now = rtc_tm_to_ktime(tm); ^~~~~~~~~~~~~~~~~~~ tm is set by a successful call to __rtc_read_time() but its return status is not checked. Check if it was successful before setting the enabled flag. Move the decl of err to function scope. Fixes: 2b2f5ff00f63 ("rtc: interface: ignore expired timers when enqueuing new timers") Signed-off-by: Tom Rix Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220326194236.2916310-1-trix@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/interface.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -793,9 +793,13 @@ static int rtc_timer_enqueue(struct rtc_ struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue); struct rtc_time tm; ktime_t now; + int err; + + err = __rtc_read_time(rtc, &tm); + if (err) + return err; timer->enabled = 1; - __rtc_read_time(rtc, &tm); now = rtc_tm_to_ktime(tm); /* Skip over expired timers */ @@ -809,7 +813,6 @@ static int rtc_timer_enqueue(struct rtc_ trace_rtc_timer_enqueue(timer); if (!next || ktime_before(timer->node.expires, next->expires)) { struct rtc_wkalrm alarm; - int err; alarm.time = rtc_ktime_to_tm(timer->node.expires); alarm.enabled = 1;