Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1497405iol; Fri, 10 Jun 2022 08:39:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyfC1c6zIV48IQFR3+2zOqn4NuCu4SWBGnokTujdk9UjRTGuNILqu65X+H6NN8ePXi/ad8 X-Received: by 2002:a17:906:9f1e:b0:711:d8bc:bbc6 with SMTP id fy30-20020a1709069f1e00b00711d8bcbbc6mr21408706ejc.266.1654875598149; Fri, 10 Jun 2022 08:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654875598; cv=none; d=google.com; s=arc-20160816; b=sWRHPIe1jixBx3zP6uQ3iLxRoklXBX15VtWFbH/IDyZNyaQL8dm0Nopvt6x4NxMCSV Dzl/bsGz8kPUBZuJPV65eFhI26KTDdda4dkiTD5cuyaAPqJBZnwdze7v8LG+iAPwuAJC Wtetq6jK14TdPd7nmgQSn9otNP/Tlol3PKxwiyQkWUDW8QkXb0MnYAjhPzIJKxBzjZZB 1EW6/S0o9bur670k/tkjyA5Du/sZjAL4Rm+PTImeW5PafVPjFbzRr/M3tR47AI/cpjEG 0SCsLD6dhwqH5UZOq3xG9QFTJtXBNm9xzsZNsmwhUr7hegCmiERUPJVE3EZ4y5+pOss4 ezJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hdBMiG23Y0l3gnCpyWCmIaQNof1wgx/FziXFWN122Vo=; b=NxIZXpbdCOrR5nnBJjcuUF9BdN+QZ+JCa493kmQgwMMvn4lYeVHLtKM0f8N6KAejDo 4YJpeRvtdUMNQ1qdrMnz0TP5GGEpk5jsL/LCAQOLa62MhLtUqMWZtH0aCwwkzoRrv2cY liDR2TeUJCf3JL//y/dGOrfzDfCt7p5185EVVqxn2pLFUsJ6WNmBQoR4wI1JGlfn3yul /T5xU5lIby/Grw0lHqfARLOyX5nGQ2JtxNTPkBp8kuL94I4LjX67pGvz60+gz8KhV38R oak840eQ19c+pkZXQoJev+0o4HUBjiQwSxfTx0VWH1SQKB2UdwBrKapiTOh59xwQ0P/h stKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp38-20020a1709071b2600b0070790bfa9a2si32252629ejc.154.2022.06.10.08.39.32; Fri, 10 Jun 2022 08:39:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240898AbiFJOsx (ORCPT + 99 others); Fri, 10 Jun 2022 10:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345899AbiFJOr7 (ORCPT ); Fri, 10 Jun 2022 10:47:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7FAF57523C for ; Fri, 10 Jun 2022 07:47:45 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3EDC01FB; Fri, 10 Jun 2022 07:47:45 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 58D9A3F73B; Fri, 10 Jun 2022 07:47:44 -0700 (PDT) Date: Fri, 10 Jun 2022 15:47:34 +0100 From: Cristian Marussi To: Ludvig =?iso-8859-1?Q?P=E4rsson?= Cc: Sudeep Holla , kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] firmware: arm_scmi: Fix incorrect error propagation Message-ID: References: <20220610140055.31491-1-ludvig.parsson@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220610140055.31491-1-ludvig.parsson@axis.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Fri, Jun 10, 2022 at 04:00:55PM +0200, Ludvig P?rsson wrote: > scmi_voltage_descriptors_get() will incorrecly return an > error code if the last iteration of the for loop that > retrieves the descriptors is skipped due to an error. > Skipping an iteration in the loop is not an error, but > the `ret` value from the last iteration will be > propagated when the function returns. > > Fix by not saving return values that should not be > propagated. This solution also minimizes the risk of > future patches accidentally reintroducing this bug. > > Signed-off-by: Ludvig P?rsson > --- Hi Ludvig, you are right, good catch. I would also say, reviewing this now, that the following line: ph->xops->reset_rx_to_maxsz it is not called when skipping (even by the original code) BUT this is not a problem given that VOLTAGE_DOMAIN_ATTRIBUTES is not a command returning a variable length reply, so it really never needed to reset the buffer size to max when called in a loop. (almost all of these command are now embedded in the iterator helpers that take care to call reset_to_maxsz on their own internally) I'll post a fix to remove that last unneeded line soon-ish. In the meantime, regarding this patch instead: Reviewed-by: Cristian Marussi Thanks for this, Cristian > drivers/firmware/arm_scmi/voltage.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/firmware/arm_scmi/voltage.c b/drivers/firmware/arm_scmi/voltage.c > index 9d195d8719ab..49b75375d3ff 100644 > --- a/drivers/firmware/arm_scmi/voltage.c > +++ b/drivers/firmware/arm_scmi/voltage.c > @@ -225,9 +225,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, > > /* Retrieve domain attributes at first ... */ > put_unaligned_le32(dom, td->tx.buf); > - ret = ph->xops->do_xfer(ph, td); > /* Skip domain on comms error */ > - if (ret) > + if (ph->xops->do_xfer(ph, td)) > continue; > > v = vinfo->domains + dom; > @@ -249,9 +248,8 @@ static int scmi_voltage_descriptors_get(const struct scmi_protocol_handle *ph, > v->async_level_set = true; > } > > - ret = scmi_voltage_levels_get(ph, v); > /* Skip invalid voltage descriptors */ > - if (ret) > + if (scmi_voltage_levels_get(ph, v)) > continue; > > ph->xops->reset_rx_to_maxsz(ph, td); > -- > 2.20.1 >