Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by David Yang
Mon, 09 Nov 2026 14:46
[PATCH net-next v2] net: dsa: motorcomm: Free the MIB block on port teardown
Author: David Yang
Date: Mon, 09 Nov 2026 14:46
Date: Mon, 09 Nov 2026 14:46
86 lines
13468 bytes
13468 bytes
.setup() can run again within one registration: removing another switch
from the tree tears the whole tree down, and re-probing sets every
member switch up again.
The hardware reset at the start of .setup() brings the MIB counters back
to zero, but a MIB block kept across that cycle still holds the old
software buffer, so the next yt921x_mib_read() treats the small value as
a 32-bit wrap and adds 2^32 to every counter it extends.
The old claim, get_stats64() not being synchronized with
.port_teardown(), is not true, thus free the MIB block in
.port_teardown(), so the next setup allocates zeroed blocks.
Not carrying a fix tag since there are no known multi-chip yt921x users.
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
v2:
- free the block on the error path
v1: https://lore.kernel.org/r/20261108101648.1308271-1-mmyangfl@gmail.com
drivers/net/dsa/motorcomm/chip.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index 33e5fc127244..7e86d992bd97 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -1994,11 +1994,11 @@ static void yt921x_dsa_port_teardown(struct dsa_switch *ds, int port)
struct yt921x_port *pp = &priv->ports[port];
struct yt921x_mib *pm = pp->mib;
- /* get_stats64() might not be synchronized with port_teardown(), hold
- * the MIB block till the device teardown
- */
- if (pm)
+ if (pm) {
disable_delayed_work_sync(&pm->work);
+ pp->mib = NULL;
+ kvfree(pm);
+ }
}
static int yt921x_dsa_port_setup(struct dsa_switch *ds, int port)
@@ -2006,12 +2006,11 @@ static int yt921x_dsa_port_setup(struct dsa_switch *ds, int port)
struct yt921x_priv *priv = dsa_to_yt921x_priv(ds);
struct yt921x_port *pp = &priv->ports[port];
const struct yt921x_info *info = priv->info;
- struct device *dev = yt921x_priv_to_device(priv);
- struct yt921x_mib *pm = pp->mib;
+ struct yt921x_mib *pm;
int res;
- if (!pm && (BIT(port) & yt921x_info_ports_mask(info))) {
- pm = devm_kzalloc(dev, sizeof(*pm), GFP_KERNEL);
+ if (BIT(port) & yt921x_info_ports_mask(info)) {
+ pm = kvzalloc_obj(*pm);
if (!pm)
return -ENOMEM;
pp->mib = pm;
@@ -2019,20 +2018,15 @@ static int yt921x_dsa_port_setup(struct dsa_switch *ds, int port)
pm->port = pp;
u64_stats_init(&pm->syncp);
INIT_DELAYED_WORK(&pm->work, yt921x_mib_poll);
- /* Start disabled, so that the enable below always pairs with
- * either this disable or the one from a previous teardown
- */
- disable_delayed_work_sync(&pm->work);
}
mutex_lock(&priv->reg_lock);
res = yt921x_port_setup(priv, port);
mutex_unlock(&priv->reg_lock);
- if (res)
+ if (res) {
+ yt921x_dsa_port_teardown(ds, port);
return res;
-
- if (pm)
- enable_delayed_work(&pm->work);
+ }
return 0;
}
--
2.53.0
Re: [PATCH net-next v2] net: dsa: motorcomm: Free the MIB block on port teardown
Author: netdev-bot+sinfo
Date: Mon, 09 Nov 2026 14:51
Date: Mon, 09 Nov 2026 14:51
22 lines
8641 bytes
8641 bytes
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. - Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages. 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. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net-next v2] net: dsa: motorcomm: Free the MIB block on port teardown
Author: David Yang
Date: Mon, 09 Nov 2026 14:52
Date: Mon, 09 Nov 2026 14:52
27 lines
12937 bytes
12937 bytes
On Mon, Nov 9, 2026 at 10:51 PM <netdev-bot+sinfo@kernel.org> wrote: > > 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. > > - Whether the issue was actually triggered, or is only theoretical > (e.g. found by code inspection). If it was triggered please include > the symptoms, like the stack trace or error messages. > > 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. If the series needs another revision for > other reasons, please include the information in the commit messages > then. > > The evaluation is done by an LLM so it may be wrong, if you think > that is the case please reply and explain. not a fix - explained in the message
Re: [PATCH net-next v2] net: dsa: motorcomm: Free the MIB block on port teardown
Author: patchwork-bot+netdevbpf
Date: Wed, 11 Nov 2026 23:20
Date: Wed, 11 Nov 2026 23:20
26 lines
8725 bytes
8725 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 9 Nov 2026 22:46:50 +0800 you wrote:
> .setup() can run again within one registration: removing another switch
> from the tree tears the whole tree down, and re-probing sets every
> member switch up again.
>
> The hardware reset at the start of .setup() brings the MIB counters back
> to zero, but a MIB block kept across that cycle still holds the old
> software buffer, so the next yt921x_mib_read() treats the small value as
> a 32-bit wrap and adds 2^32 to every counter it extends.
>
> [...]
Here is the summary with links:
- [net-next,v2] net: dsa: motorcomm: Free the MIB block on port teardown
https://git.kernel.org/netdev/net-next/c/a9a173f81c83
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads