netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Nathan Chancellor <nathan@kernel.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	clang-built-linux@googlegroups.com
Subject: [PATCH AUTOSEL 5.4 056/109] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe()
Date: Thu,  9 Sep 2021 07:54:13 -0400	[thread overview]
Message-ID: <20210909115507.147917-56-sashal@kernel.org> (raw)
In-Reply-To: <20210909115507.147917-1-sashal@kernel.org>

From: Nathan Chancellor <nathan@kernel.org>

[ Upstream commit 4367355dd90942a71641c98c40c74589c9bddf90 ]

When compiling with clang in certain configurations, an objtool warning
appears:

drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.o: warning: objtool:
ipq806x_gmac_probe() falls through to next function phy_modes()

This happens because the unreachable annotation in the third switch
statement is not eliminated. The compiler should know that the first
default case would prevent the second and third from being reached as
the comment notes but sanitizer options can make it harder for the
compiler to reason this out.

Help the compiler out by eliminating the unreachable() annotation and
unifying the default case error handling so that there is no objtool
warning, the meaning of the code stays the same, and there is less
duplication.

Reported-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../ethernet/stmicro/stmmac/dwmac-ipq806x.c    | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index 0f56f8e33691..03b11f191c26 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -288,10 +288,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
 		val &= ~NSS_COMMON_GMAC_CTL_PHY_IFACE_SEL;
 		break;
 	default:
-		dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
-			phy_modes(gmac->phy_mode));
-		err = -EINVAL;
-		goto err_remove_config_dt;
+		goto err_unsupported_phy;
 	}
 	regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
 
@@ -308,10 +305,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
 			NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
 		break;
 	default:
-		dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
-			phy_modes(gmac->phy_mode));
-		err = -EINVAL;
-		goto err_remove_config_dt;
+		goto err_unsupported_phy;
 	}
 	regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
 
@@ -328,8 +322,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
 				NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id);
 		break;
 	default:
-		/* We don't get here; the switch above will have errored out */
-		unreachable();
+		goto err_unsupported_phy;
 	}
 	regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val);
 
@@ -360,6 +353,11 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_unsupported_phy:
+	dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
+		phy_modes(gmac->phy_mode));
+	err = -EINVAL;
+
 err_remove_config_dt:
 	stmmac_remove_config_dt(pdev, plat_dat);
 
-- 
2.30.2


  parent reply	other threads:[~2021-09-09 13:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210909115507.147917-1-sashal@kernel.org>
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 006/109] tipc: keep the skb in rcv queue until the whole data is read Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 008/109] iavf: do not override the adapter state in the watchdog task Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 009/109] iavf: fix locking of critical sections Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 012/109] netlink: Deal with ESRCH error in nlmsg_notify() Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 015/109] igc: Check if num of q_vectors is smaller than max before array access Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 026/109] bpf/tests: Fix copy-and-paste error in double word test Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 027/109] bpf/tests: Do not PASS tests without actually testing the result Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 031/109] ipv4: ip_output.c: Fix out-of-bounds warning in ip_copy_addrs() Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 032/109] flow_dissector: Fix out-of-bounds warnings Sasha Levin
2021-09-09 11:53 ` [PATCH AUTOSEL 5.4 040/109] samples: bpf: Fix tracex7 error raised on the missing argument Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 043/109] Bluetooth: skip invalid hci_sync_conn_complete_evt Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 045/109] bonding: 3ad: fix the concurrency between __bond_release_one() and bond_3ad_state_machine_handler() Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 048/109] bpf: Fix off-by-one in tail call count limiting Sasha Levin
2021-09-09 11:54 ` Sasha Levin [this message]
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 058/109] selftests/bpf: Fix xdp_tx.c prog section name Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 059/109] Bluetooth: schedule SCO timeouts with delayed_work Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 060/109] Bluetooth: avoid circular locks in sco_sock_connect Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 061/109] net/mlx5: Fix variable type to match 64bit Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 064/109] mac80211: Fix monitor MTU limit so that A-MSDUs get through Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 070/109] Bluetooth: Fix handling of LE Enhanced Connection Complete Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 073/109] tcp: enable data-less, empty-cookie SYN with TFO_SERVER_COOKIE_NOT_REQD Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 074/109] rpc: fix gss_svc_init cleanup on failure Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 090/109] selftests/bpf: Enlarge select() timeout for test_maps Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 100/109] iwlwifi: mvm: fix a memory leak in iwl_mvm_mac_ctxt_beacon_changed Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 101/109] iwlwifi: mvm: avoid static queue number aliasing Sasha Levin
2021-09-09 11:54 ` [PATCH AUTOSEL 5.4 102/109] iwlwifi: mvm: fix access to BSS elements Sasha Levin
2021-09-09 11:55 ` [PATCH AUTOSEL 5.4 103/109] net/mlx5: DR, Enable QP retransmission Sasha Levin
2021-09-09 11:55 ` [PATCH AUTOSEL 5.4 105/109] ath9k: fix OOB read ar9300_eeprom_restore_internal Sasha Levin
2021-09-09 11:55 ` [PATCH AUTOSEL 5.4 106/109] ath9k: fix sleeping in atomic context Sasha Levin
2021-09-09 11:55 ` [PATCH AUTOSEL 5.4 107/109] net: fix NULL pointer reference in cipso_v4_doi_free Sasha Levin
2021-09-09 11:55 ` [PATCH AUTOSEL 5.4 108/109] fix array-index-out-of-bounds in taprio_change Sasha Levin
2021-09-09 11:55 ` [PATCH AUTOSEL 5.4 109/109] net: w5100: check return value after calling platform_get_resource() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909115507.147917-56-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=nathan@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).