From: netdev-bot+sashiko@kernel.org
To: xietangxin@h-partners.com
Cc: kuba@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@kernel.org, pabeni@redhat.com, dlinkin@nvidia.com,
vladbu@nvidia.com, jiri@resnulli.us, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
syzbot+bbd81e1e2276c534dea1@syzkaller.appspotmail.com,
gaoxingwang1@huawei.com, huyizhen2@huawei.com,
xuanqiang.luo@linux.dev
Subject: Re: [PATCH net v2] netdevsim: fix rate node leak during reload and removal
Date: Wed, 25 Nov 2026 11:22:50 +0000 [thread overview]
Message-ID: <179560577028.3135.18386607599971206035@kernel.org> (raw)
In-Reply-To: <20261121110858.1337003-1-xietangxin@h-partners.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The fix is incomplete: rate nodes still leak, and the same
WARNs still fire, when the device has been left in the devlink…
--
netdevsim: fix rate node leak during reload and removal
nsim_dev_reload_destroy() now checks the eswitch mode unconditionally.
Rate nodes created on a zero-VF switchdev device are then destroyed via
nsim_esw_legacy_enable() -> devl_rate_nodes_destroy() on both reload and
removal, which avoids the devlink_free() and
devlink_reload_reinit_sanity_check() WARNs.
Link: https://lore.kernel.org/all/17cc4251-04ae-41a7-a872-fc5cf525b58f@linux.dev/
> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
> index c6b17b3873271..b483c25dfecdd 100644
> --- a/drivers/net/netdevsim/dev.c
> +++ b/drivers/net/netdevsim/dev.c
> @@ -1700,11 +1700,10 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
> return;
> debugfs_remove(nsim_dev->take_snapshot);
>
> - if (nsim_dev_get_vfs(nsim_dev)) {
> + if (nsim_dev_get_vfs(nsim_dev))
> nsim_bus_dev_set_vfs(nsim_dev->nsim_bus_dev, 0);
> - if (nsim_esw_mode_is_switchdev(nsim_dev))
> - nsim_esw_legacy_enable(nsim_dev, NULL);
> - }
> + if (nsim_esw_mode_is_switchdev(nsim_dev))
> + nsim_esw_legacy_enable(nsim_dev, NULL);
[Severity: Medium]
Can rate nodes still leak when the device is in the reload_failed state?
The new unconditional check sits after the early return at the top of
nsim_dev_reload_destroy():
drivers/net/netdevsim/dev.c:nsim_dev_reload_destroy() {
...
if (devlink_is_reload_failed(devlink))
return;
...
}
When reload_failed is set, devl_rate_nodes_destroy() is never reached.
Nothing seems to stop rate nodes from being created while reload_failed
is set. One possible sequence:
1) devlink dev reload runs nsim_dev_reload_down(), which resets
esw_mode to legacy. nsim_dev_reload_up() then fails, either through
the fail_reload debugfs knob (returns -EINVAL) or through an error in
nsim_dev_reload_create(). devlink_reload() then calls:
devlink_reload_failed_set(devlink, !!err);
2) devlink dev eswitch set ... mode switchdev still succeeds. With zero
VFs, nsim_esw_switchdev_enable() only does:
nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;
No devlink command in net/devlink/ checks reload_failed.
3) devlink port function rate add .../n1 also succeeds.
devlink_nl_rate_new_doit() has no reload_failed check, and
nsim_rate_node_new() only checks nsim_esw_mode_is_switchdev(). The
node is added to devlink->rate_list.
4) del_device leads to nsim_drv_remove() -> nsim_dev_reload_destroy(),
which returns early. nsim_drv_remove() has no other rate cleanup, so
devlink_free() hits:
WARN_ON(devlink_rates_check(devlink, NULL, NULL));
The devlink_rate and nsim_rate_node allocations and their debugfs
directories are leaked.
If step 4 is a second devlink dev reload instead,
nsim_dev_reload_down() -> nsim_dev_reload_destroy() returns early again,
and the WARN in devlink_reload_reinit_sanity_check() fires.
These are the same two WARNs the commit message describes. The early
return is older than this patch. However, the subject promises to fix the
rate node leak during reload and removal, and this case is still
reachable.
Would it make sense to also destroy the rate nodes before the
reload_failed early return, or in nsim_drv_remove()?
>
> nsim_dev_port_del_all(nsim_dev);
> nsim_dev_hwstats_exit(nsim_dev);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121110858.1337003-1-xietangxin%40h-partners.com
prev parent reply other threads:[~2026-11-25 11:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 11:08 xietangxin
2026-11-23 8:09 ` Xuanqiang Luo
2026-11-25 11:22 ` netdev-bot+sashiko [this message]
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=179560577028.3135.18386607599971206035@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dlinkin@nvidia.com \
--cc=edumazet@kernel.org \
--cc=gaoxingwang1@huawei.com \
--cc=huyizhen2@huawei.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+bbd81e1e2276c534dea1@syzkaller.appspotmail.com \
--cc=vladbu@nvidia.com \
--cc=xietangxin@h-partners.com \
--cc=xuanqiang.luo@linux.dev \
/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
all inboxes | Powered by JetHome®