Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3687910lfo; Mon, 23 May 2022 11:28:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwowmotS+mUAv2YBLCT1EmcFzN4EvCzDetrPGxnSf2i0VcfRtCsnyNRgWuHbjL42+1PCQ8g X-Received: by 2002:a65:6d06:0:b0:3c6:890:5609 with SMTP id bf6-20020a656d06000000b003c608905609mr20853882pgb.357.1653330522386; Mon, 23 May 2022 11:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330522; cv=none; d=google.com; s=arc-20160816; b=JJzEdUU/xGPLBkk7J6HS/hG/QxFBx50aUuToF9YCSpuNF6XRG8lJrhiIVR0HfkBytW +94k5W1DJ21j9Tnk2dYB6txC9yW3iRDexLllGr6NIIkMo3cxRj8i/ZWKifCfUlmylERf MA1g9O60mZ2hh+qZcpUgZUvSFh2pl8XdTnCpeED1rGgbupE63j2fVqkdkqjJBSEXpg4O nZXsXEZyWA5/+Hu0EgyeHdNZZjR0bbk5DW2xmnMFngfUUMzWBeI+ht3VbjNMT4bNd4S/ nC4CRjuD1r86sE0aJ4UCmko10Oryq73+ZqbVTxYY2trx84LLp4AC7wur9SPumKepxCV0 q/vw== 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=fK6LFUyLqi93OvezPPWL/ysclgpNviKouhGLcmekBZ4=; b=C6uFrWTV22O3R1fZDMCNG4OYQZv4QwUqI76tksXTs/b2rzzA5qQZUs61SWOj8xLI8C VgHqpejhe0RdSc7U+kAhdZ02qZ6AcEEGEru+cWIzBglA50oxhsYckEb5GD0kevzTW2gW NoxEj4QWcJ/f7Ttfx7eQ6wcSqvBtqSH2B28o5bOQAel+AYr8+CQZXzuTzID6YdTbqG5x 0+LC6lwvugwKLe3wNlAw0sF1kD5R1z4YHR4vrUKIweGsj+FhjNnkhlPuPmqKMFh2WlvR fJ2v0qHfJx+iseaO03Yk5o9HA3KU3lfvEUUB8/5M5kmEOI1t2LKvC1YaGVTiA0/fJLmK dN3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ToqgX9tt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id ot13-20020a17090b3b4d00b001cd46bee4c2si133482pjb.7.2022.05.23.11.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:28:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ToqgX9tt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 7C59CCC16A; Mon, 23 May 2022 11:28:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241399AbiEWR0q (ORCPT + 99 others); Mon, 23 May 2022 13:26:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240222AbiEWRRc (ORCPT ); Mon, 23 May 2022 13:17:32 -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 9D63971A10; Mon, 23 May 2022 10:17:20 -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 7E50560919; Mon, 23 May 2022 17:17:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62D28C385A9; Mon, 23 May 2022 17:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326239; bh=yC99/wYz6UhC2zfmoGGY9wbZug421pD2Jlmf8Cdzo/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToqgX9ttx3tVM3OxZ8tM4VYkkZPzDMcCR/P1P1DiF3iu1z6znvmXWl3yte5voSk0F ss/JqHvw4JLk4sKJZWjGy25OtYKISMfeCY4CheMFBy5N9MTKnZdcugJKsU/Aqgg//y gFJTu/IheA74ls+OGhMSaQ2d0IdunF1bK8wF0kSM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hugo Villeneuve , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.15 020/132] rtc: pcf2127: fix bug when reading alarm registers Date: Mon, 23 May 2022 19:03:49 +0200 Message-Id: <20220523165826.874169570@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165823.492309987@linuxfoundation.org> References: <20220523165823.492309987@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.6 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=unavailable 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: Hugo Villeneuve [ Upstream commit 73ce05302007eece23a6acb7dc124c92a2209087 ] The first bug is that reading the 5 alarm registers results in a read operation of 20 bytes. The reason is because the destination buffer is defined as an array of "unsigned int", and we use the sizeof() operator on this array to define the bulk read count. The second bug is that the read value is invalid, because we are indexing the destination buffer as integers (4 bytes), instead of indexing it as u8. Changing the destination buffer type to u8 fixes both problems. Signed-off-by: Hugo Villeneuve Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220208162908.3182581-1-hugo@hugovil.com Signed-off-by: Sasha Levin --- drivers/rtc/rtc-pcf2127.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c index 56c58b055dff..43f801107095 100644 --- a/drivers/rtc/rtc-pcf2127.c +++ b/drivers/rtc/rtc-pcf2127.c @@ -374,7 +374,8 @@ static int pcf2127_watchdog_init(struct device *dev, struct pcf2127 *pcf2127) static int pcf2127_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct pcf2127 *pcf2127 = dev_get_drvdata(dev); - unsigned int buf[5], ctrl2; + u8 buf[5]; + unsigned int ctrl2; int ret; ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL2, &ctrl2); -- 2.35.1