net: txgbe: fix stack size for PHY interface mask
Subsystems (3)
PATCH v5 1/1 net: txgbe: fix stack size for PHY interface mask
The DECLARE_PHY_INTERFACE_MASK_ZERO() macro currently defined in the txgbe driver incorrectly uses PHY_INTERFACE_MODE_MAX as the array length instead of BITS_TO_LONGS(). This allocates significantly more space on the stack than necessary.
Since hiding the zero-initialization inside a macro is discouraged, drop the local macro entirely and use the standard DECLARE_PHY_INTERFACE_MASK() with explicit zero-initialization at the declaration site instead.
---
Changes since v4:
- replace DECLARE_PHY_INTERFACE_MASK_ZERO with DECLARE_PHY_INTERFACE_MASK and initialize it to { 0, }.
Links:
- https://lore.kernel.org/all/[email protected]/ (v3)
- https://lore.kernel.org/all/[email protected]/ (v4)
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c | 4 ++-- drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c +2 -2
@@ -202,7 +202,7 @@ void txgbe_set_phy_link(struct wx *wx)static int txgbe_sfp_to_linkmodes (struct wx *wx,struct txgbe_sff_id *id) {__ETHTOOL_DECLARE_LINK_MODE_MASK (modes) = {0 , }; -DECLARE_PHY_INTERFACE_MASK_ZERO (interfaces); +DECLARE_PHY_INTERFACE_MASK (interfaces) = {0 , };struct txgbe *txgbe = wx->priv;if (id->cable_tech &TXGBE_SFF_DA_PASSIVE_CABLE ) {
@@ -269,7 +269,7 @@ static int txgbe_sfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)static int txgbe_qsfp_to_linkmodes (struct wx *wx,struct txgbe_sff_id *id) {__ETHTOOL_DECLARE_LINK_MODE_MASK (modes) = {0 , }; -DECLARE_PHY_INTERFACE_MASK_ZERO (interfaces); +DECLARE_PHY_INTERFACE_MASK (interfaces) = {0 , };struct txgbe *txgbe = wx->priv;if (id->transceiver_type &TXGBE_SFF_ETHERNET_40G_CR4 ) {
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h +0 -3
@@ -315,9 +315,6 @@ void txgbe_up(struct wx *wx);int txgbe_setup_tc (struct net_device *dev,u8 tc);void txgbe_do_reset (struct net_device *netdev,bool reinit); -#define DECLARE_PHY_INTERFACE_MASK_ZERO (name) \ - unsigned long name[PHY_INTERFACE_MODE_MAX] = { 0, } -#define TXGBE_LINK_SPEED_UNKNOWN 0#define TXGBE_LINK_SPEED_10GB_FULL 4#define TXGBE_LINK_SPEED_25GB_FULL 0x10
Signature · 1 line
2.47.3
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Hi Coia,
Quoted 5 lines · Coia Prant
The
DECLARE_PHY_INTERFACE_MASK_ZERO()macro currently defined in the txgbe driver incorrectly usesPHY_INTERFACE_MODE_MAXas the array length instead ofBITS_TO_LONGS(). This allocates significantly more space on the stack than necessary.
Quoted 8 lines
Since hiding the zero-initialization inside a macro is discouraged, drop the local macro entirely and use the standard
DECLARE_PHY_INTERFACE_MASK()with explicit zero-initialization at the declaration site instead.Fixes 47f848aac4e7 ("net: txgbe: initialize PHY interface to 0")Signed-off-by Coia Prant <[email protected]>Cc Jiawen Wu <[email protected]>
I'm OK with the patch itself, but that should go to net-next.
Please resent there, feel free to add
Maxime
Paolo Abeni
maintainerQuoted 5 lines · Coia Prant
The
DECLARE_PHY_INTERFACE_MASK_ZERO()macro currently defined in the txgbe driver incorrectly usesPHY_INTERFACE_MODE_MAXas the array length instead ofBITS_TO_LONGS(). This allocates significantly more space on the stack than necessary.
Quoted 8 lines
Since hiding the zero-initialization inside a macro is discouraged, drop the local macro entirely and use the standard
DECLARE_PHY_INTERFACE_MASK()with explicit zero-initialization at the declaration site instead.Fixes 47f848aac4e7 ("net: txgbe: initialize PHY interface to 0")Signed-off-by Coia Prant <[email protected]>Cc Jiawen Wu <[email protected]>
As already mentioned, IMHO this is net-next material, not worthy a fixes tag.
No need to repost, I'll fix while I'll apply it.
/P
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Wed, 18 Nov 2026 01:55:28 +0800 you wrote:
The
DECLARE_PHY_INTERFACE_MASK_ZERO()macro currently defined in the txgbe driver incorrectly usesPHY_INTERFACE_MODE_MAXas the array length instead ofBITS_TO_LONGS(). This allocates significantly more space on the stack than necessary.Since hiding the zero-initialization inside a macro is discouraged, drop the local macro entirely and use the standard
DECLARE_PHY_INTERFACE_MASK()with explicit zero-initialization at the declaration site instead.[...]
Here is the summary with links:
- [net,v5] net: txgbe: fix stack size for PHY interface mask
https://git.kernel.org/netdev/net-next/c/60cf8fade566
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html