Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1436794iol; Fri, 10 Jun 2022 07:31:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu5F8AghEVXfylXWGWpWHS6Wd2cOSYQUim3QV57XOBKubSZLdZob/8RML07BYZTNUUx1bT X-Received: by 2002:a17:907:1c07:b0:711:c966:f02e with SMTP id nc7-20020a1709071c0700b00711c966f02emr26670040ejc.221.1654871514894; Fri, 10 Jun 2022 07:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654871514; cv=none; d=google.com; s=arc-20160816; b=K38Kv1j3K5z8qRSNCAQXs6QMuA4VMbR2ljdS8zwFscNxHSPV+Rrk+TqduJCR36Tz3p rg+y+7Vlk0t1QqVA4AezCg3lzD6ZTANbFbRCaQT549Zm7L93D2/jD4cIFTpzUsH0ZSXq UNp4+Jsr4M2KEVwvv8OB2JXW9DQS0izquCNa2M57lEspLEjWS80L5USKqb5C58D/ozEa OpCa7RWKDL1BiUK2ls7aRfFrU/A8Wx83Z8N4W5exBHEoGBMhtz2OfVQKGysg1CJP7qhq YSxZW6eszpzJsfbsjc947B7GJWJH/cbSoZXclKo392lKdXWnDN1jfyY4kQ9r3/Sb68sd 7xIg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=d28BFi0/VBb4bixwduhrFurpMjara8WE4vvBx38KIlM=; b=Kp5If39MglXaMcLlXpDTjgpYYKZv/rjx721WpIwCjaWuEgTRkNNcfqc3U5uLrbBPwa WDu8hOH/lhRI3B8Rm7HEC0ObPYMcAcRf068NnU78mKb7xzzp52KxdFILQk8FV0rs1et9 0GzHrXe6+Uieg2z9TXLpm3mJ6ssybDWfiyDugywWTFHs+b9+hVFiP3BqQMUc5G/zaqMY BIDaZQ42SXlJRn4e1AwK2cjNNHKBh+28KEx3dMs8PMzf3vFn4gKMN4e/r+wlGV4q4P79 NMTcF6V+fRwXoz75Tsi1ZJvwR73e5sFdLsWecAYakev76VqJrAOkGqmBgYF+P69lA5jp +oOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=AdpReraq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j24-20020a170906535800b006ff47216539si7311507ejo.537.2022.06.10.07.31.28; Fri, 10 Jun 2022 07:31:54 -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; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=AdpReraq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242731AbiFJOB7 (ORCPT + 99 others); Fri, 10 Jun 2022 10:01:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349401AbiFJOBq (ORCPT ); Fri, 10 Jun 2022 10:01:46 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5757A2B72CB for ; Fri, 10 Jun 2022 07:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1654869704; x=1686405704; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=d28BFi0/VBb4bixwduhrFurpMjara8WE4vvBx38KIlM=; b=AdpReraq0AkSip49aWoRClfjN7eVD7yOg5a0Hs45GnA0QlTdmFoMtmpZ QQXgUuFgSoWtlV7dtc7HRkESCGamdr4nd0sAl+rvLtfh04vYR1c0u41LW yk1j81ly7OYyFENBoeOZiC2F3mrqujITE9nAwaYF69hcsHGSECLvSLmXg mKMmPgx84uuNBCttj4dg339C94id9YMf2Oo4Mky8VVYiQJmoulN7GqyCh lwy7sKQtMm7pmmbGkK/N7sa6V6kT9x50P4BBABQPrc3CrDmppi4pBc9EM dkgxi36MLdrrlhrVEkh7ZiSK20aDPlYrkdKdjAs/eYKoTRpJuCcQqmH4D w==; From: =?UTF-8?q?Ludvig=20P=C3=A4rsson?= To: Sudeep Holla CC: , =?UTF-8?q?Ludvig=20P=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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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 --- 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