From patchwork Sat Jan 8 15:50:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12707519 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 7796DC433EF for ; Sat, 8 Jan 2022 15:52:13 +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=tAassodnUJbP3rB+e4u5yUwzSePvyeAgMTy3CcYbhlw=; b=zeEVa+aoolYVbT lTwRkQTki4PsmLnX1lBb9VTmPIePX/lS24S9tMG/0N5+lv7RWPeGYesooJLTnYmdmmYFdHGpXGTAq jD6W3UQ2YLE5c3VEILp5O7N+UYMRmyci5KZ3rX30yhySqy+AgwNmvdOC9ROYNHf+M8pqPDXi1SOdK NToS5N240QgaIzL0N5Cj2HK3YfAr1+5E6mHHkHC4UqMOB7K7nD5wqoTXM700qov3AUB+rFonRyKcQ V8ZlwLONg70j3TmdkzHty2PN775b/hq+82TnSVTBjwFuk9mbutNg8tA1kbfJNw5fDgq0mSPwyztUQ mEsp8wdhxuynofqC6AQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n6Dz3-006cSs-SE; Sat, 08 Jan 2022 15:50:22 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n6Dz0-006cSH-A2 for linux-arm-kernel@lists.infradead.org; Sat, 08 Jan 2022 15:50:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641657017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nutHqRyjAUxs0OigylRB1piW55HI8TWHHwTVtcKgRN8=; b=cZjKZJsKHrNjeiD+HJK0lddxE923vMoFxOIxZkEKrx2UOM2jHu49Kx3AT3wojBGRxCjBF7 Nq09ycHKkbs2YHXIpwbzMyCaKWqSrvGYTY7JrYC84p48cznaZk6iF+7c5rvD7/FT1K7rsT xQyFD5koH4Pss1NGCus6cNnkE+S4bUs= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-57-ZMIUdt2KNn2IIE0MjrZVpg-1; Sat, 08 Jan 2022 10:50:09 -0500 X-MC-Unique: ZMIUdt2KNn2IIE0MjrZVpg-1 Received: by mail-oi1-f197.google.com with SMTP id y74-20020aca4b4d000000b002c6fd8df444so6262480oia.22 for ; Sat, 08 Jan 2022 07:50:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nutHqRyjAUxs0OigylRB1piW55HI8TWHHwTVtcKgRN8=; b=HgYzpCDmG4t005d95Wam64x0EUInqAZx1s8ghlk9CXDYQWTElyp0350cRDMLT6q58h i7ewpqX3u/6O0fKMKNhpwkO3eQ1+vx6SSRBtbvIiP7hEgMQycV3NfhDAeCZtATVuX/T3 GhU+5Gyey9SX9euFe1ufqc5l+Kq8pvEwRRJwWbWe+lhaw5qwqOQ6g88d+dwFFrl+kRFF rujXFCMddYMFOgLjIpG1LiP2ub5gLHbRS1hEWDSkxNzn1firTcFPEuCTQTxkwut0GF3X PzJY6FR0pEgs11WFdv0ldc26S3h9V8nOdYlzu1wcXxRSVWiK5l7MD+k9dsvK2sR6sAx3 0qJA== X-Gm-Message-State: AOAM533Iz2hRCPklI2IJIUzKdI5xndow07nfUdZ/iZ+CQu/0PwDuu4VA g9Mk/4Gu+2NckMQUMKWenJTqc9FB12fhTqa9bDgr/+VtW3T2gmUp5Z5ewvrhYU2tcKu11BxSxlM iFp64SIUzxFCw83+FN6ZlRnRTIzB2yXvxsEg= X-Received: by 2002:a4a:d5d5:: with SMTP id a21mr43792305oot.43.1641657008670; Sat, 08 Jan 2022 07:50:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDAnHZJpVjRqSRJBkvJ07yYIEgasx5S6n/t1vzZoDi6lprUw7Ku1TMowLE/zzd5lBQtwBZWg== X-Received: by 2002:a4a:d5d5:: with SMTP id a21mr43792283oot.43.1641657008487; Sat, 08 Jan 2022 07:50:08 -0800 (PST) Received: from localhost.localdomain.com (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id q13sm384815otf.76.2022.01.08.07.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jan 2022 07:50:08 -0800 (PST) From: trix@redhat.com To: nbd@nbd.name, john@phrozen.org, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, davem@davemloft.net, kuba@kernel.org, matthias.bgg@gmail.com, linux@armlinux.org.uk, nathan@kernel.org, ndesaulniers@google.com, opensource@vdorst.com Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Tom Rix Subject: [PATCH] net: ethernet: mtk_eth_soc: fix error checking in mtk_mac_config() Date: Sat, 8 Jan 2022 07:50:03 -0800 Message-Id: <20220108155003.3991055-1-trix@redhat.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220108_075018_435570_DC0CD7B4 X-CRM114-Status: GOOD ( 12.27 ) 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 From: Tom Rix Clang static analysis reports this problem mtk_eth_soc.c:394:7: warning: Branch condition evaluates to a garbage value if (err) ^~~ err is not initialized and only conditionally set. Check err consistently with the rest of mtk_mac_config(), after even possible setting. Fixes: 7e538372694b ("net: ethernet: mediatek: Re-add support SGMII") Signed-off-by: Tom Rix --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b67b4323cff08..a27e548488584 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -385,14 +385,16 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, 0 : mac->id; /* Setup SGMIISYS with the determined property */ - if (state->interface != PHY_INTERFACE_MODE_SGMII) + if (state->interface != PHY_INTERFACE_MODE_SGMII) { err = mtk_sgmii_setup_mode_force(eth->sgmii, sid, state); - else if (phylink_autoneg_inband(mode)) + if (err) + goto init_err; + } else if (phylink_autoneg_inband(mode)) { err = mtk_sgmii_setup_mode_an(eth->sgmii, sid); - - if (err) - goto init_err; + if (err) + goto init_err; + } regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0, SYSCFG0_SGMII_MASK, val);