From: sashiko-bot@kernel.org
To: "Runyu Xiao" <runyu.xiao@seu.edu.cn>
Cc: linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: Re: [PATCH] can: hi311x: drop hi3110_lock before free_irq() on open failure
Date: Thu, 20 Aug 2026 02:20:20 +0000 [thread overview]
Message-ID: <20260820022021.70B381F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260820020631.316418-1-runyu.xiao@seu.edu.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent execution of `hi3110_clean` due to a missing lock in `hi3110_do_set_mode` can lead to a double-free (use-after-free) of `priv->tx_skb`.
- [High] The driver fails to cancel pending works in `hi3110_stop` and `hi3110_can_remove`, allowing deferred I/O on stopped or powered-off hardware.
--
--- Patch [1]: [PATCH] can: hi311x: drop hi3110_lock before free_irq() on open failure ---
commit d2d3a5df6413395872456083be56586448f72c40
Author: Runyu Xiao <runyu.xiao@seu.edu.cn>
can: hi311x: drop hi3110_lock before free_irq() on open failure
hi3110_open() requests a threaded IRQ and then performs hardware setup
while holding priv->hi3110_lock. The patch fixes a deadlock by dropping
the lock before free_irq() in the open rollback path.
Cc: stable@vger.kernel.org
> diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
> index ae90e6716de5b..2be851e8907d0 100644
> --- a/drivers/net/can/spi/hi311x.c
> +++ b/drivers/net/can/spi/hi311x.c
[ ... ]
[Severity: High]
This is a pre-existing issue, but can this lead to a double-free of
priv->tx_skb?
If hi3110_do_set_mode() is called (e.g. via netlink for manual bus-off
recovery), it unconditionally calls hi3110_clean() without acquiring
priv->hi3110_lock:
drivers/net/can/spi/hi311x.c:hi3110_do_set_mode() {
...
case CAN_MODE_START:
hi3110_clean(net);
...
}
Concurrently, hi3110_tx_work_handler() can access and free priv->tx_skb
under the lock:
drivers/net/can/spi/hi311x.c:hi3110_tx_work_handler() {
...
frame = (struct can_frame *)priv->tx_skb->data;
...
}
Since hi3110_clean() frees priv->tx_skb unconditionally without the lock,
could both threads attempt to process and free the exact same sk_buff
simultaneously?
[Severity: High]
This isn't a bug introduced by this patch, but is there a risk of running
deferred I/O on stopped or powered-off hardware?
In hi3110_stop(), the device state is torn down without cancelling
pending works like priv->restart_work and priv->tx_work:
drivers/net/can/spi/hi311x.c:hi3110_stop() {
struct hi3110_priv *priv = netdev_priv(net);
...
}
Furthermore, during driver unbind, hi3110_can_remove() disables hardware
power before destroying the workqueue:
drivers/net/can/spi/hi311x.c:hi3110_can_remove() {
...
unregister_candev(net);
hi3110_power_enable(priv->power, 0);
destroy_workqueue(priv->wq);
...
}
Since destroy_workqueue() flushes pending works, could this cause the works
to execute on powered-off hardware and unregistered netdevs?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260820020631.316418-1-runyu.xiao@seu.edu.cn?part=1
prev parent reply other threads:[~2026-08-20 2:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 2:06 [PATCH] can: hi311x: drop hi3110_lock before free_irq() on open failure Runyu Xiao
2026-08-20 2:20 ` sashiko-bot [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=20260820022021.70B381F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=runyu.xiao@seu.edu.cn \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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