Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp640854pxb; Tue, 5 Apr 2022 16:59:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgBuD0oSyJvhXurWcqd23fyVc053Bu2lTQ6g3daR1wa8ns3xS2uoxe3/llo/hp9P2rcCyy X-Received: by 2002:a17:90b:3889:b0:1c6:408b:6b0f with SMTP id mu9-20020a17090b388900b001c6408b6b0fmr6768144pjb.43.1649203197642; Tue, 05 Apr 2022 16:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649203197; cv=none; d=google.com; s=arc-20160816; b=rEdz+zL6fFxSf/pnO6C2r2hLLRIpgKKA59RCbg4O5Uaubg2I9kCP4mTdWHrAjp1Pin BptRFbv8LmcOASI7pRx73wepU7zLXY6wpI90HYrh1Qil3ta00acbcZMbV6cfHASmmIUF ujvg8rZ6TVy/7XX780GWvHk59x20qQyhFQUz199szDs+I1HHhzdfDJtMSB68ADgO+nnq vCM3rQkLPWL+lLpc9XR5JsNIfD1zKO4iNzSYPr5sAYtb3UzBalSnfMc7ClkCOyGS5OyO QjdzOaKHMkg73+K59lwZzj/O0C8hmqsAf8BADQqB1LvhoT4+7/B/KrxfLyz/JeLYu4ME PMlA== 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=mVHf3aL6dttuRK8d2ZihvcTQxjzZ01YntOywhJjKD68=; b=bdIw7VO5CXbBdl+abBbiEqt7wwSs5foLlXnkLPl8gamMZCOGMyHhfrFm4d4+G6t/mQ XmOD7QuDD4uLDtp1jQFHUlj6Oz/pOA4koKLxkwI/hANT6/8APQt98Ga6ArMzLrykRhr2 c5NtvxfeWpxVoMMK5MBRiegjOg+FVpi2DXRgKi26VL34MmPRhdi+heDvPFqDHcsEFTlE N1IMi0nv7yjlNgdJ8xT04yrrr3GU7EFIvUULgnWdKWXByYOm7vMyeCOeNSUuhkYpXJ2y sAHcjNiCCMmBxD/zN+MtLgW3t0BateaXXfpDCfirLPpSVq2QEIV1TWHQ0aLxIA0ka2hF 632A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PyE5dJAx; 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 s12-20020a17090302cc00b001566dc4c545si12716768plk.395.2022.04.05.16.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:59:57 -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=PyE5dJAx; 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F94628E359; Tue, 5 Apr 2022 16:46:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390017AbiDENgC (ORCPT + 99 others); Tue, 5 Apr 2022 09:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346605AbiDEJYa (ORCPT ); Tue, 5 Apr 2022 05:24:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D1F9B28; Tue, 5 Apr 2022 02:13:48 -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 ams.source.kernel.org (Postfix) with ESMTPS id 448EFB81C77; Tue, 5 Apr 2022 09:13:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACC27C385A6; Tue, 5 Apr 2022 09:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150025; bh=1P7dqhC2TaTndTPDyXwVbqmJovUDvfg+vmyr+QM2+nU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PyE5dJAxszd9e6Fk7uDWyJqe3op38l8lFh3icx2Caw6sa405NQxtbEpdKZwGEwiCt 3TwIarIsSd/rNxx83t0hoc8oq/M1dQSjaoynyJhroFaJ+TX6a1kDO/gRf4Govi5KIq rfkaFr2/Al0WMZg1QKZ+1Zv7H5I4T1gZcBUzdWqI= 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.16 0928/1017] rtc: check if __rtc_read_time was successful Date: Tue, 5 Apr 2022 09:30:41 +0200 Message-Id: <20220405070421.761859139@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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 @@ -804,9 +804,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 */ @@ -820,7 +824,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;