From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8186C43334 for ; Fri, 10 Jun 2022 14:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7h+2SGHaw8kH8n93GqadyFnYFCeRPIKuQSluFGPJHsk=; b=F3HHdoyeyPW8Gw FOr9LVoOiwmwF+BjhIY7eqb8WzJo7+zqW8HSbdGvGs/VrlweJ3FD/xIk7BSwoJnlJFzgWF66UzXjS favwihy5YKueEdQkUK8u7GucVkNKg4gpE0izZ1b1Gg63UmFt4ZHngoIifdfm+K6nQGS8EbSBBoE3I pYsndlG3I/SJZbfrGk603iMFH3yeYTBFNYrT8noipV7S2xd8nenUQk6tO5uHBt7Uli7cDKgoEVc1X 7JfjoYp1+yL47SitfUlbixK/fBEWBAiQ3pXeaCgHnd9bpRdJJVElF3sy6uk4SKHZKfYU37oNgVcA2 EDl5AbwDa1dbqcsWsZYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzfvY-008dl4-AI; Fri, 10 Jun 2022 14:47:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzfvT-008dhF-Nz for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 14:47:53 +0000 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-Disposition: inline In-Reply-To: <20220610140055.31491-1-ludvig.parsson@axis.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_074751_869333_1614C1D1 X-CRM114-Status: GOOD ( 24.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 10, 2022 at 04:00:55PM +0200, Ludvig P=E4rsson 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=E4rsson > --- 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_s= cmi/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 =3D ph->xops->do_xfer(ph, td); > /* Skip domain on comms error */ > - if (ret) > + if (ph->xops->do_xfer(ph, td)) > continue; > = > v =3D vinfo->domains + dom; > @@ -249,9 +248,8 @@ static int scmi_voltage_descriptors_get(const struct = scmi_protocol_handle *ph, > v->async_level_set =3D true; > } > = > - ret =3D 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 > = _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel