From patchwork Fri Jun 10 14:00:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludvig_P=C3=A4rsson?= X-Patchwork-Id: 12877640 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 B9C42C43334 for ; Fri, 10 Jun 2022 14:03:02 +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:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tkCRMHrouV4FbXVxHYq8keGT2BShSHAewP4uP0RIbRo=; b=T6lpUpfWtzaFeh XVEhUC32cjp+d3RtIqH43zYYycURZ1t4VrWIkKs5Jibz5Yz5IRuVpeUZ/wWfJFN//U2EB6F5ktbDp oP+9YzWf2T+XvaPT9npJUsVNVPQSMyzgIgSmkhANtGR+QqGjkFbswkiLWhvBD3wP/n0P9e0ynoWwy e4Fz+6/YwKeyBgPzCHAhLKSPCP3F00Xg5+NXJSO37tW9N+vj98C/G2k6jF7OXA3BjrmSUXgi5mIeB yym4zjl6bZq9vmw2qfNBR4CRSBJ+RvSMuKao1Vr3ZQxgDRPDWY4QE4TpjE9XCaI2sJP0/zT0hlvsN KeDr67Ubfvx91txx4Xyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzfD1-008Ugv-P9; Fri, 10 Jun 2022 14:01:55 +0000 Received: from smtp1.axis.com ([195.60.68.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzfCy-008Ued-2K for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 14:01:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1654869712; x=1686405712; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=d28BFi0/VBb4bixwduhrFurpMjara8WE4vvBx38KIlM=; b=mK172EssNjCtbuR2me4GBLfagrkwMe9xDY72mu+EbKkcScqfFXRzNJOg Rh3xg/EW9RoQDjiGSjBMUhUPVU/8vLHjTVNotbOQ/GSsRa9nSqEDktzRv WEIiWbejjCOCJuF3fEykuk+Kh6QkJemiSeHKYdw3Ou26gAzM8L+XYaSKT ARcKlReVe9osHPVTk/4/d19QJYveLbI1QjHQMjySJIDILtsQAjAwc2w2D DW0lfIBHMCFjSGK8VpXCuGrHxblNBZpPuniJgduMXKYjszwNatFmXEAvp ZvRfFUnE4ZLyp7BjNB7ddaNwwGzAJmTf+z7ifJ7kvixZ77m2Bj/h3X7hO A==; From: =?utf-8?q?Ludvig_P=C3=A4rsson?= To: Sudeep Holla CC: , =?utf-8?q?Ludvig_P=C3=A4rsson?= , Cristian Marussi , , Subject: [PATCH] firmware: arm_scmi: Fix incorrect error propagation Date: Fri, 10 Jun 2022 16:00:55 +0200 Message-ID: <20220610140055.31491-1-ludvig.parsson@axis.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_070152_483963_9198AE3D X-CRM114-Status: GOOD ( 11.05 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Cristian Marussi --- 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);