[PATCH net] net: cxgb3: Ignore link changes on PHY read errors

Ruoyu Wang <[email protected]>
Newsgroups org.kernel.vger.netdev,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
PHY link-status callbacks can fail before initializing all their output
parameters. For example, an MI1 timeout in get_link_status_r() leaves
link_ok unset, but t3_link_changed() then uses it to update MAC and
carrier state.

Return without changing link state when the callback fails. A later poll
or PHY event can retry the update with valid values.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: 4d22de3e6cc4 ("Add support for the latest 1G/10G Chelsio adapter, T3.")
Signed-off-by: Ruoyu Wang <[email protected]>
---
 drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index a06003bfa04b9..cc04d21564253 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -1180,7 +1180,8 @@ void t3_link_changed(struct adapter *adapter, int port_id)
 	struct cmac *mac = &pi->mac;
 	struct link_config *lc = &pi->link_config;
 
-	phy->ops->get_link_status(phy, &link_ok, &speed, &duplex, &fc);
+	if (phy->ops->get_link_status(phy, &link_ok, &speed, &duplex, &fc))
+		return;
 
 	if (!lc->link_ok && link_ok) {
 		u32 rx_cfg, rx_hash_high, rx_hash_low;
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.