From: netdev-bot+sashiko@kernel.org
To: yuanhsinte@chromium.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, hayeswang@realtek.com,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
yuanhsinte@google.com
Subject: Re: [PATCH net] r8152: do not (un)register the PM notifier under RTNL
Date: Tue, 24 Nov 2026 12:30:35 +0000 [thread overview]
Message-ID: <179552343569.3135.5205506648034787768@kernel.org> (raw)
In-Reply-To: <20261123-r8152-pm-notifier-rtnl-v1-1-31e011a2ee51@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
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).
- [High] Moving unregister_pm_notifier() out of rtl8152_close() removes
the only thing that kept rtl_notifier() from racing ndo_stop.
- [Low] The commit author address does not match the Signed-off-by
address.
--
r8152: do not (un)register the PM notifier under RTNL
This patch moves register_pm_notifier() and unregister_pm_notifier() out
of the ndo_open and ndo_stop handlers. They now run in
rtl8152_probe_once(), its error path and rtl8152_disconnect(), which
avoids a deadlock between RTNL and the PM notifier chain rwsem. It also
adds a PM_NOTIFIER_AUTOPM_HELD flag, so the runtime PM reference taken
by rtl_notifier() is only dropped if it was actually taken.
> Fixes: 5ee3c60c8d3b ("r8152: fix the wake event")
> Signed-off-by: Hsin-Te Yuan <yuanhsinte@google.com>
[Severity: Low]
The Author line uses yuanhsinte@chromium.org, but the only Signed-off-by
uses yuanhsinte@google.com. Should these match?
checkpatch reports this as FROM_SIGN_OFF_MTCH ("From:/Signed-off-by:
email address mismatch").
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index d3bb7ee9c9bf3..fea47a8924149 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
[ ... ]
> @@ -7155,9 +7158,6 @@ static int rtl8152_close(struct net_device *netdev)
> struct r8152 *tp = netdev_priv(netdev);
> int res = 0;
>
> -#ifdef CONFIG_PM_SLEEP
> - unregister_pm_notifier(&tp->pm_notifier);
> -#endif
> tasklet_disable(&tp->tx_tl);
> clear_bit(WORK_ENABLE, &tp->flags);
> usb_kill_urb(tp->intr_urb);
[Severity: High]
Can rtl_notifier() now race with rtl8152_close()?
Before this patch, rtl8152_close() started with unregister_pm_notifier(),
which does down_write(&pm_chain_head.rwsem). That call waited for the
whole PM_SUSPEND_PREPARE chain to finish, including the synchronous
runtime resume started from rtl_notifier():
rtl_notifier()
usb_autopm_get_interface()
rtl8152_resume() /* takes tp->control */
rtl8152_runtime_resume()
The notifier now stays registered for the whole lifetime of the device.
Nothing seems to stop this path from overlapping ndo_stop.
rtl8152_runtime_resume() checks netif_running() once and then does:
tp->rtl_ops.autosuspend_en(tp, false);
napi_disable(napi);
set_bit(WORK_ENABLE, &tp->flags);
...
napi_enable(napi);
...
usb_submit_urb(tp->intr_urb, GFP_NOIO);
At the same time, __dev_close_many() holds RTNL, clears
__LINK_STATE_START and calls rtl8152_close(). That function does the
following without tp->control or an autopm reference:
tasklet_disable(&tp->tx_tl);
clear_bit(WORK_ENABLE, &tp->flags);
usb_kill_urb(tp->intr_urb);
cancel_delayed_work_sync(&tp->schedule);
napi_disable(&tp->napi);
If the napi_disable() in close runs first, would the napi_disable() in
rtl8152_runtime_resume() loop forever? NAPI stays disabled until the
next open. The resuming task holds tp->control and holds
pm_chain_head.rwsem for read.
rtl8152_close() would then block in usb_autopm_get_interface(), waiting
for that resume while still holding RTNL. That looks like the same
suspend/RTNL hang the commit message describes.
If the napi_disable() in the resume path runs first, close waits for its
napi_enable(). The resume path then sets WORK_ENABLE and resubmits
tp->intr_urb, which undoes the teardown. Close then continues into
rtl_ops.down() and free_all_mem():
free_all_mem()
usb_free_urb(tp->intr_urb);
tp->intr_urb = NULL;
kfree(tp->intr_buff);
tp->intr_buff = NULL;
Is the interrupt URB still queued at the HCD at that point? If so,
intr_callback() would read the freed tp->intr_buff and resubmit the URB.
That would be a use-after-free, with DMA into freed memory.
Other autoresume sources, such as remote wakeup or hw_phy_work, can
already race close this way. The PM notifier, though, is a new trigger
added by this change.
This needs an interface that is up but runtime-suspended, and an ifdown
that runs at the same time as the start of system suspend or
hibernation. PREPARE notifiers run before tasks are frozen, so these two
can overlap.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-r8152-pm-notifier-rtnl-v1-1-31e011a2ee51%40google.com
prev parent reply other threads:[~2026-11-24 12:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 12:29 [PATCH net] r8152: do not (un)register the PM notifier under RTNL Hsin-Te Yuan
2026-11-23 12:32 ` netdev-bot+sinfo
2026-11-24 3:28 ` Hsin-Te Yuan
2026-11-24 12:30 ` 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=179552343569.3135.5205506648034787768@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hayeswang@realtek.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yuanhsinte@chromium.org \
--cc=yuanhsinte@google.com \
/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