]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: txgbe: distinguish module types by checking identifier
authorJiawen Wu <jiawenwu@trustnetic.com>
Mon, 8 Jun 2026 07:08:41 +0000 (15:08 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 11 Jun 2026 08:55:14 +0000 (10:55 +0200)
Rework txgbe_identify_module() to validate module identifiers through
explicit type checks instead of relying on transceiver_type heuristics.
When using the SFP module, transceiver_type could be a random value,
because it was read from an invalid register.

Fixes: 57d39faed4c9 ("net: txgbe: improve functions of AML 40G devices")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Link: https://patch.msgid.link/20260608070842.36504-3-jiawenwu@trustnetic.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c

index a7e81f9e1be1482cc2e49d730a8dbe7b8627b6a1..bdac654a236465de5ee5d66003869fa7170e53c6 100644 (file)
@@ -357,18 +357,16 @@ int txgbe_identify_module(struct wx *wx)
        }
 
        id = &buffer.id;
-       if (id->identifier != TXGBE_SFF_IDENTIFIER_SFP &&
-           id->identifier != TXGBE_SFF_IDENTIFIER_QSFP &&
-           id->identifier != TXGBE_SFF_IDENTIFIER_QSFP_PLUS &&
-           id->identifier != TXGBE_SFF_IDENTIFIER_QSFP28) {
-               wx_err(wx, "Invalid module\n");
-               return -ENODEV;
-       }
-
-       if (id->transceiver_type == 0xFF)
+       if (id->identifier == TXGBE_SFF_IDENTIFIER_SFP)
                return txgbe_sfp_to_linkmodes(wx, id);
 
-       return txgbe_qsfp_to_linkmodes(wx, id);
+       if (id->identifier == TXGBE_SFF_IDENTIFIER_QSFP ||
+           id->identifier == TXGBE_SFF_IDENTIFIER_QSFP_PLUS ||
+           id->identifier == TXGBE_SFF_IDENTIFIER_QSFP28)
+               return txgbe_qsfp_to_linkmodes(wx, id);
+
+       wx_err(wx, "Invalid module\n");
+       return -EINVAL;
 }
 
 void txgbe_setup_link(struct wx *wx)