Thread View: linux.kernel.netdev
58 messages
58 total messages
Page 2 of 2
Started by Marc Kleine-Budde
Fri, 09 Oct 2026 13:27
Page 2 of 2 • 58 total messages
Re: [PATCH net-next 20/37] dt-bindings: can: renesas,rcar-canfd: Restrict resets in top-level
Author: netdev-bot+sashiko
Date: Sat, 10 Oct 2026 14:03
Date: Sat, 10 Oct 2026 14:03
132 lines
9797 bytes
9797 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] The binding never makes `resets`/`reset-names` required for
RZ/G3L (`renesas,r9a08g046-canfd`), although the driver treats it…
- [Low] The commit message says the patch disallows "reset-names" for the
two R-Car variants (renesas,rcar-gen3-canfd and renesas,rcar-…
--
dt-bindings: can: renesas,rcar-canfd: Restrict resets in top-level
This commit adds top-level minItems: 1 and maxItems: 2 limits to the
resets property. It drops the per-variant maxItems: 2 lines, which the new
top-level limit makes redundant. It also adds reset-names: false to the
R-Car gen3/gen4 conditional block.
Link: https://patch.msgid.link/20261001060825.53335-2-krzysztof.kozlowski@oss.qualcomm.com
> diff --git a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
> index cef20f0403715..4b94bc8d911be 100644
> --- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
> +++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
[ ... ]
> @@ -232,6 +233,8 @@ allOf:
> resets:
> maxItems: 1
>
> + reset-names: false
> +
[Severity: Low]
The commit message says:
Since top-level part says "reset-names" cannot accept one item, disallow
it for the two variants which do not use it in practice.
Weren't these two variants already blocked from using reset-names before
this patch? Further down in allOf there is an existing block for the same
two compatibles:
- if:
properties:
compatible:
contains:
enum:
- renesas,rcar-gen3-canfd
- renesas,rcar-gen4-canfd
then:
required:
- resets
properties:
reset-names: false
The patch doesn't touch that block. As a result, the added
reset-names: false copies a constraint that already exists, and validation
results don't change.
Could the added line be dropped, or one of the two copies removed and the
commit message reworded? As written, the message describes a behaviour
change that this patch doesn't make.
> - if:
> properties:
> compatible:
> @@ -247,7 +250,6 @@ allOf:
>
> resets:
> minItems: 2
> - maxItems: 2
>
[Severity: Medium]
This patch reworks the per-variant reset constraints. Should
renesas,r9a08g046-canfd (RZ/G3L) also be added to the allOf block that
requires resets and reset-names? That block currently lists only:
- if:
properties:
compatible:
contains:
enum:
- renesas,r9a08g045-canfd
- renesas,r9a09g047-canfd
- renesas,rzg2l-canfd
then:
required:
- resets
- reset-names
The RZ/G3L block only sets resets: minItems: 2. That constraint applies
only when resets is present.
The driver handles RZ/G3L exactly like RZ/G3S. In
drivers/net/can/rcar/rcar_canfd.c:
{ .compatible = "renesas,r9a08g046-canfd", .data = &r9a08g045_hw_info },
rcar_canfd_probe() looks up both resets by name as optional:
gpriv->rstc1 = devm_reset_control_get_optional_exclusive(dev, "rstp_n");
...
gpriv->rstc2 = devm_reset_control_get_optional_exclusive(dev, "rstc_n");
Consider an r9a08g046 node with no resets, or with resets but no
reset-names. It passes dtbs_check, and probe gets NULL handles. Then, in
rcar_canfd_global_init(), the calls
err = reset_control_reset(gpriv->rstc1);
...
err = reset_control_reset(gpriv->rstc2);
do nothing, and rcar_canfd_reset_controller() runs on a block that may
still be held in reset.
This gap came from the earlier commit in this series,
"dt-bindings: can: renesas,rcar-canfd: Document RZ/G3L SoC", not from this
patch. It is still present at the end of the series.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009134323.64064-2-mkl%40pengutronix.de
Re: [PATCH net-next 24/37] can: cc770: don't discard the IRQ lookup error in probe
Author: netdev-bot+sashiko
Date: Sat, 10 Oct 2026 14:03
Date: Sat, 10 Oct 2026 14:03
56 lines
7371 bytes
7371 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message describes a user-visible failure ("a probe
that has to wait for its interrupt controller is never retried and the…
--
can: cc770: don't discard the IRQ lookup error in probe
This patch changes cc770_platform_probe() so that it checks the memory
resource first. It then returns the platform_get_irq() error unchanged
instead of turning every failure into -ENODEV, so -EPROBE_DEFER now
reaches the driver core.
Link: https://patch.msgid.link/20261009105556.301821-1-quchaosheng000406@163.com
> That discards -EPROBE_DEFER, so a probe that has to wait for its
> interrupt controller is never retried and the device stays unbound.
[Severity: Low]
Does any real configuration hit this failure?
The code change looks correct, and so do the technical claims in the
message:
- platform_get_irq() passes -EPROBE_DEFER through.
- call_driver_probe() handles -ENODEV and -ENXIO the same way.
The only in-tree users of cc770_platform are powerpc device trees.
arch/powerpc/boot/dts/tqm8548.dts and tqm8548-bigflash.dts:
compatible = "bosch,cc770";
interrupt-parent = <&mpic>;
arch/powerpc/boot/dts/tqm8xx.dts:
compatible = "intc,82527";
interrupt-parent = <&PIC>;
The MPIC and the 8xx PIC are both set up during init_IRQ, so these
boards should not see -EPROBE_DEFER. No in-tree board file registers
the device through platform data.
The message describes a failure that users would see, but it has no
Fixes: tag. Could it say whether this was seen on real hardware, or
whether it is a robustness and consistency cleanup? Without that, stable
backporters cannot tell which it is.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009134323.64064-2-mkl%40pengutronix.de
Re: [PATCH net-next 26/37] can: ems_usb: use usb_kill_urb() to stop the intr URB
Author: netdev-bot+sashiko
Date: Sat, 10 Oct 2026 14:03
Date: Sat, 10 Oct 2026 14:03
169 lines
11790 bytes
11790 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message describes the disconnect race and leaves out
the more easily reached ifdown/reopen failure that this change also…
Pre-existing issues:
- [Critical] Double free of the DMA-coherent RX buffers in
drivers/net/can/usb/ems_usb.c.
- [Medium] ems_usb_start() returns errors after URBs are already in
flight and does not stop them, and ems_usb_open() does not clean up…
--
can: ems_usb: use usb_kill_urb() to stop the intr URB
This commit replaces usb_unlink_urb() with usb_kill_urb() for the
interrupt URB in unlink_all_urbs(). Teardown now waits for
ems_usb_read_interrupt_callback() to return before ems_usb_disconnect()
frees intr_in_buffer and the candev.
Link: https://patch.msgid.link/20260923030522.409344-1-fanwu01@zju.edu.cn
> The handler can therefore still be running while ems_usb_disconnect()
> frees its data: it reads the transfer buffer dev->intr_in_buffer, which
> is kfree()d there, and dereferences the private context, which is
> released via free_candev() together with the network device.
[Severity: Low]
This disconnect window does exist, but it is fairly narrow.
ems_usb_driver does not set soft_unbind, so usb_unbind_interface() does
this before calling ->disconnect:
drivers/usb/core/driver.c:usb_unbind_interface() {
...
if (!driver->soft_unbind || udev->state == USB_STATE_NOTATTACHED)
usb_disable_interface(udev, intf, false);
driver->disconnect(intf);
...
}
usb_disable_interface() reaches usb_hcd_flush_endpoint(), which kills
the URBs still queued on the endpoint. The only case left is a URB that
the HCD has already dequeued but whose BH giveback has not run yet.
The ifdown path seems easier to hit. In ems_usb_close(), the old
usb_unlink_urb() call did not raise urb->reject. So if the intr URB
completed with status 0 at that moment, the handler resubmitted it:
ems_usb_read_interrupt_callback() {
...
case 0:
dev->free_slots = dev->intr_in_buffer[1];
...
err = usb_submit_urb(urb, GFP_ATOMIC);
...
}
The URB then kept polling after ifdown. The next ems_usb_open() failed
with -EBUSY, and usb_submit_urb() printed the "URB submitted while
active" WARN. This patch fixes that case too.
Should the commit message mention it, since stable backporters may use
it to judge impact?
> The handler treats the -ENOENT completion of a killed URB as terminal and
> does not take RTNL or any sleeping lock, so the resubmit loop is cut and
> no RTNL deadlock occurs.
If the URB completes with status 0 just as it is being killed, the
handler does not see -ENOENT. In that case the loop is stopped by
urb->reject in usb_kill_urb(): the resubmit fails and "failed
resubmitting intr urb" is logged. Could the wording reflect both cases?
> diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
> index 24cf8f651f8f1..2d31f0b86859c 100644
> --- a/drivers/net/can/usb/ems_usb.c
> +++ b/drivers/net/can/usb/ems_usb.c
> @@ -748,7 +748,7 @@ static void unlink_all_urbs(struct ems_usb *dev)
> {
> int i;
>
> - usb_unlink_urb(dev->intr_urb);
> + usb_kill_urb(dev->intr_urb);
>
> usb_kill_anchored_urbs(&dev->rx_submitted);
>
[Severity: Critical]
This is a pre-existing issue and was not introduced by this patch. It is
in the same function and on the same disconnect path, though. Can the
RX coherent buffers be freed twice here?
The loop right after this frees each buffer but never clears the saved
pointers:
for (i = 0; i < MAX_RX_URBS; ++i)
usb_free_coherent(dev->udev, RX_BUFFER_SIZE,
dev->rxbuf[i], dev->rxbuf_dma[i]);
If the interface has been opened at least once, the first free happens
in ems_usb_close(). That runs on a normal ifdown, or from
unregister_netdev() when the device is unplugged while up.
ems_usb_disconnect() then calls unlink_all_urbs() again:
ems_usb_disconnect()
unregister_netdev(dev->netdev); -> ems_usb_close()->unlink_all_urbs()
unlink_all_urbs(dev); -> usb_free_coherent() on same rxbuf[]
hcd_buffer_free() only skips NULL addresses. So the stale pointers go on
to dma_pool_free(), kfree() or gen_pool_free() a second time.
A similar case: after an open/close cycle, a later ems_usb_start() can
leave its RX loop early on an alloc or submit failure. The remaining
rxbuf[] slots then still point at buffers that were already freed.
The free loop came from commit 9969e3c5f40c ("can: ems_usb:
ems_usb_start(): fix possible memory leak"). Would setting
dev->rxbuf[i] = NULL after the free fix this? Another option would be to
avoid the second unlink_all_urbs() call in ems_usb_disconnect().
[Severity: Medium]
This is also pre-existing and was not introduced by this patch. Can
ems_usb_start() return an error while URBs are still in flight?
If the intr URB submit fails, the function returns with the RX URBs
still anchored on dev->rx_submitted and running:
err = usb_submit_urb(dev->intr_urb, GFP_KERNEL);
if (err) {
netdev_warn(netdev, "intr URB submit failed: %d\n", err);
return err;
}
If a later ems_usb_control_cmd() or ems_usb_write_mode() fails, the
failed label only prints a warning and returns. The intr URB and the RX
URBs keep running.
ems_usb_open() handles this with only close_candev(). ndo_stop is not
called after a failed ndo_open, so unlink_all_urbs() never runs. Both
completion handlers keep resubmitting while the interface is down.
On the next open, usb_submit_urb() on the still-active intr_urb hits:
if (urb->hcpriv) {
WARN_ONCE(1, "URB %p submitted while active\n", urb);
return -EBUSY;
}
The open keeps failing until the device is replugged.
Each retry also overwrites dev->rxbuf[] and dev->rxbuf_dma[]. That leaks
the coherent buffers from the earlier attempt: disconnect kills their
URBs through the anchor but never frees the buffers.
With this patch, disconnect at least kills the leftover intr URB
synchronously.
Should the ems_usb_start() error paths kill the intr URB and the
anchored RX URBs before returning?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009134323.64064-2-mkl%40pengutronix.de
Re: [PATCH net-next 29/37] can: f81604: f81604_close(): fix use-after-free on disconnect
Author: netdev-bot+sashiko
Date: Sat, 10 Oct 2026 14:03
Date: Sat, 10 Oct 2026 14:03
205 lines
13158 bytes
13158 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 2 (2) · Medium: 0 (1) · 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] The fix only covers ndo_stop.
- [High] The fix reorders only one of the two works that the int URB
completion handler can schedule.
- [Low] The patch fixes a use-after-free and carries 'Cc:
stable@vger.kernel.org', but the commit message has no Fixes: tag.
Pre-existing issues:
- [High] Each bus-off restart submits a new set of URBs on top of the
ones that are already running.
- [High] f81604_close() calls close_candev() -> can_flush_echo_skb()
(line 1078) while URB completions can still use priv->echo_skb[0].
- [Medium] f81604_close() puts the controller into reset mode with IER
off (f81604_set_reset_mode(), line 1075) before it stops the async…
--
can: f81604: f81604_close(): fix use-after-free on disconnect
This commit moves cancel_work_sync(&priv->clear_reg_work) in f81604_close()
to after f81604_unregister_urbs(). After that change, an URB completion
handler can no longer schedule clear_reg_work once the cancel has returned.
The goal is to stop the work from running after the netdev and private data
are freed.
Closes: https://lore.kernel.org/all/20260824133009.CF85A1F00A3A@smtp.kernel.org/
Link: https://patch.msgid.link/20260901-f81604-fix-v1-1-c55b5178f9f8@fintek.com.tw
> Cc: stable@vger.kernel.org
[Severity: Low]
This isn't a bug, but should this have a Fixes: tag next to the stable Cc?
The teardown order in f81604_close() looks unchanged since the driver was
added, so the tag would be:
Fixes: 88da17436973 ("can: usb: f81604: add Fintek F81604 support")
> diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c
> index 4c147b9d6d690..bb155b8769245 100644
> --- a/drivers/net/can/usb/f81604.c
> +++ b/drivers/net/can/usb/f81604.c
> @@ -1075,10 +1075,10 @@ static int f81604_close(struct net_device *netdev)
> f81604_set_reset_mode(priv);
[Severity: Medium]
This is a pre-existing issue, but can a bus-off restart running at the same
time undo this reset? can_restart_work()->can_restart() does not take RTNL.
The restart_work timer could fire while f81604_set_reset_mode() is doing
its control transfers:
can_restart()
f81604_set_mode(CAN_MODE_START)
f81604_start()
f81604_set_normal_mode()
clears MOD.RM, writes IER = IRQ_ALL & ~RI
In that case, cancel_delayed_work_sync() in close_candev() only waits for
the restart to finish. f81604_unregister_urbs() then kills the URBs the
restart submitted, but nothing puts the chip back into reset mode.
Would ndo_stop then return with the SJA1000 core still in operating mode on
the bus while the netdev is down?
>
> netif_stop_queue(netdev);
> - cancel_work_sync(&priv->clear_reg_work);
> close_candev(netdev);
[Severity: High]
This reorders clear_reg_work, but doesn't restart_work have the same
problem? close_candev() runs cancel_delayed_work_sync(&priv->restart_work)
here, but the int URB stays live until f81604_unregister_urbs() below.
Suppose an int URB completes in that window with F81604_SJA1000_IRQ_EI and
SR.BS set. f81604_handle_can_bus_errors() then does:
if (data->sr & F81604_SJA1000_SR_BS)
can_state = CAN_STATE_BUS_OFF;
...
if (can_state == CAN_STATE_BUS_OFF)
can_bus_off(netdev);
If restart_ms is set, can_bus_off() re-arms the work:
if (priv->restart_ms)
schedule_delayed_work(&priv->restart_work,
msecs_to_jiffies(priv->restart_ms));
The interrupt report could be a buffered or in-flight one, or come from a
malicious device. It can also arrive if the IER-off write in
f81604_set_reset_mode() failed, because f81604_close() ignores its return
value.
Nothing cancels restart_work after that. When it fires,
can_restart()->f81604_set_mode()->f81604_start() puts the chip back into
normal mode, resubmits the URBs and wakes the queue on an interface that is
down.
If the device is unplugged before restart_ms expires,
f81604_disconnect()->unregister_netdev() skips ndo_stop because the device
is already down. free_candev() then frees can_priv while the restart_work
timer is still armed.
Would it be better to call f81604_unregister_urbs() before close_candev(),
as gs_usb and peak_usb do?
[Severity: High]
This is a pre-existing issue, but can close_candev()->can_flush_echo_skb()
race here with URB completions that use priv->echo_skb[0]?
The int URB is only killed later, by f81604_unregister_urbs(). The TX URBs
from f81604_start_xmit() are never anchored, so they are never killed or
waited for:
f81604_start_xmit()
can_put_echo_skb(skb, netdev, 0, 0);
ret = usb_submit_urb(write_urb, GFP_ATOMIC);
can_flush_echo_skb() checks and frees echo_skb[i] without a lock.
f81604_handle_tx() does the same through can_get_echo_skb() and
can_free_echo_skb(). f81604_write_bulk_callback() does it through
can_free_echo_skb() on error statuses. Both run in completion context.
If both sides see a non-NULL echo_skb[0], could the skb be freed twice? Or
could __can_get_echo_skb() read it after the flush has freed it?
Killing all URBs, including TX, before close_candev() looks like it would
avoid this.
>
> f81604_unregister_urbs(priv);
> + cancel_work_sync(&priv->clear_reg_work);
[Severity: High]
This covers ndo_stop, but can clear_reg_work still be left pending after a
failed open? In f81604_start(), the URBs are already live when
f81604_set_normal_mode() runs:
ret = f81604_register_urbs(priv);
if (ret)
return ret;
ret = f81604_set_normal_mode(priv);
if (ret) {
f81604_unregister_urbs(priv);
return ret;
}
The int URB may complete with error bits in isrc during
f81604_set_normal_mode(). If so, f81604_handle_can_bus_errors() calls
schedule_work(&priv->clear_reg_work).
If f81604_set_normal_mode() then fails (for example -ENODEV during
hot-unplug), the error path kills the URBs but does not cancel the work.
f81604_open() then only calls close_candev().
Since the open failed, IFF_UP is never set, so on disconnect:
f81604_disconnect()
unregister_netdev()
netif_close_many() skips ndo_stop for devices without IFF_UP
free_candev()
frees the netdev and the embedded f81604_port_priv
Could f81604_clear_reg_work() then run on the freed priv?
Would adding cancel_work_sync() to the f81604_start() error path, or
calling it unconditionally in f81604_disconnect() before free_candev(),
cover this case?
[Severity: High]
This is a pre-existing issue, but does each bus-off restart submit another
set of URBs on top of the ones already running?
can_restart()->f81604_set_mode() calls f81604_start(). f81604_start() then
calls f81604_register_urbs() without calling f81604_unregister_urbs()
first. The completion callbacks resubmit on success, so nothing kills the
open-time URBs at bus-off.
Each restart would then leave another F81604_MAX_RX_URBS bulk URBs plus an
int URB in flight, with their buffers, until ndo_stop.
Also, if f81604_set_normal_mode() fails during a restart, the error path
calls f81604_unregister_urbs(), which kills every anchored URB, including
the open-time set. Would the interface then stay up with no RX or int URBs
until the next down/up?
>
> return 0;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009134323.64064-2-mkl%40pengutronix.de
Re: [PATCH net-next 30/37] can: hi311x: drop hi3110_lock before free_irq() on open failure
Author: netdev-bot+sashiko
Date: Sat, 10 Oct 2026 14:03
Date: Sat, 10 Oct 2026 14:03
139 lines
10836 bytes
10836 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (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 rollback in hi3110_open() (drivers/net/can/spi/hi311x.c,
lines 789-794) sets priv->force_quit = 1 and drops hi3110_lock before…
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but the driver's
own restart_work is never cancelled or flushed during shutdown.
--
can: hi311x: drop hi3110_lock before free_irq() on open failure
This patch changes the hi3110_open() error path. It now sets force_quit
and drops hi3110_lock before calling free_irq(), then takes the mutex
again for the remaining hardware cleanup. This avoids a deadlock against
the threaded IRQ handler, which takes hi3110_lock before it checks
force_quit.
Link: https://patch.msgid.link/20260820020631.316418-1-runyu.xiao@seu.edu.cn
> diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
> index 076a3efa1bfff..927555b5d581e 100644
> --- a/drivers/net/can/spi/hi311x.c
> +++ b/drivers/net/can/spi/hi311x.c
> @@ -787,7 +787,10 @@ static int hi3110_open(struct net_device *net)
> return 0;
>
> out_free_irq:
> + priv->force_quit = 1;
> + mutex_unlock(&priv->hi3110_lock);
> free_irq(spi->irq, priv);
[Severity: Medium]
Can this rollback turn the old deadlock into an IRQ storm when
hi3110_set_normal_mode() fails?
The IRQ is requested with IRQF_ONESHOT | IRQF_TRIGGER_HIGH. Before
hi3110_set_normal_mode() returns -EBUSY, it has already armed the chip:
drivers/net/can/spi/hi311x.c:hi3110_set_normal_mode() {
hi3110_write(spi, HI3110_WRITE_INTE, HI3110_INT_BUSERR |
HI3110_INT_RXFIFO | HI3110_INT_TXCPLT);
hi3110_write(spi, HI3110_WRITE_CTRL1, HI3110_CTRL1_TXEN);
...
hi3110_write(spi, HI3110_WRITE_CTRL0, reg);
mdelay(HI3110_OST_DELAY_MS);
reg = hi3110_read(spi, HI3110_READ_CTRL0);
if ((reg & HI3110_CTRL0_MODE_MASK) != reg)
return -EBUSY;
...
}
A received frame or a bus error during the mdelay() window can assert
INT. Once force_quit is set, hi3110_can_ist() skips the whole
while (!priv->force_quit) loop. It never reads STATF, the FIFO or INTF,
but it still returns IRQ_HANDLED.
irq_finalize_oneshot() then unmasks the line, which is still asserted.
The interrupt fires again right away, so the SCHED_FIFO IRQ thread spins
until free_irq() finally shuts the line down.
If the IRQ thread was blocked on hi3110_lock, the new mutex_unlock()
wakes it. On the same CPU (always the case on UP), it can preempt the
opener, which holds RTNL, before the opener reaches free_irq().
The opener then only runs again through RT throttling or the fair
dl_server. That bounds the stall to about one RT period by default, but
the stall can be indefinite if those safeguards are disabled.
Would it be better to quiet the chip while still holding the mutex,
before force_quit is set and the lock is dropped? That could mirror
what hi3110_stop() does:
hi3110_write(spi, HI3110_WRITE_CTRL1, 0x0);
hi3110_write(spi, HI3110_WRITE_INTE, 0x0);
hi3110_read(spi, HI3110_READ_INTF);
Another option is calling disable_irq_nosync() before mutex_unlock().
hi3110_stop() already uses the same force_quit then free_irq() ordering
while INTE is still enabled, so the same hazard exists there. In the
open() rollback path, though, it is new with this patch.
> + mutex_lock(&priv->hi3110_lock);
> hi3110_hw_sleep(spi);
> out_close:
> hi3110_power_enable(priv->transceiver, 0);
[Severity: Medium]
This is a pre-existing issue that this patch did not introduce, but is
priv->restart_work ever cancelled or flushed on shutdown?
hi3110_do_set_mode() queues it for CAN_MODE_START:
drivers/net/can/spi/hi311x.c:hi3110_do_set_mode() {
...
priv->restart_tx = 1;
if (priv->can.restart_ms == 0)
priv->after_suspend = HI3110_AFTER_SUSPEND_RESTART;
queue_work(priv->wq, &priv->restart_work);
...
}
hi3110_stop() calls close_candev(), which only cancels the CAN core's
delayed restart_work. It never calls
cancel_work_sync(&priv->restart_work), and neither does the hi3110_open()
rollback.
If the work is still pending at ifdown or during a failed open(),
hi3110_restart_work_handler() can run after cleanup. It takes
hi3110_lock and calls hi3110_hw_reset(), hi3110_setup() and
hi3110_set_normal_mode(), which re-arms INTE, TXEN and normal mode. It
then clears force_quit and calls netif_wake_queue() on the downed
interface.
The controller would then be back on the bus while the interface is
administratively down.
The new unlocked window around free_irq() in hi3110_open() gives the
worker one more place to run. It does not seem to make things worse than
the existing post-stop case, because free_irq() still completes and the
rollback then calls hi3110_hw_sleep().
There is no use-after-free here, because hi3110_can_remove() runs
destroy_workqueue() before free_candev().
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009134323.64064-2-mkl%40pengutronix.de
Re: [PATCH net-next 35/37] can: sun4i_can: sun4ican_probe(): fix clk leak
Author: netdev-bot+sashiko
Date: Sat, 10 Oct 2026 14:03
Date: Sat, 10 Oct 2026 14:03
116 lines
9265 bytes
9265 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 (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).
- [High] The fix is incomplete: the of_clk_get() clock reference still
leaks when the device is removed.
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but
sun4ican_probe() replaces the real error codes from of_clk_get() and…
--
can: sun4i_can: sun4ican_probe(): fix clk leak
This commit adds an exit_put_clk label to sun4ican_probe(). The clock
reference taken with of_clk_get() is now released with clk_put() when
platform_get_irq(), devm_platform_ioremap_resource(), alloc_candev() or
register_candev() fails.
Link: https://patch.msgid.link/20260917104514.2147347-1-vulab@iscas.ac.cn
> diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
> index af52285d5a4e0..311526107ed81 100644
> --- a/drivers/net/can/sun4i_can.c
> +++ b/drivers/net/can/sun4i_can.c
> @@ -854,13 +854,13 @@ static int sun4ican_probe(struct platform_device *pdev)
> irq = platform_get_irq(pdev, 0);
> if (irq < 0) {
> err = -ENODEV;
> - goto exit;
> + goto exit_put_clk;
> }
[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch, but
this block is being touched anyway. Does replacing the return value of
platform_get_irq() with -ENODEV break probe deferral?
platform_get_irq() can return -EPROBE_DEFER. For example, of_irq_get()
returns it when irq_find_host() cannot find the interrupt controller
domain yet.
The of_clk_get() error path a few lines above does the same thing:
clk = of_clk_get(np, 0);
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "unable to request clock\n");
err = -ENODEV;
goto exit;
}
of_clk_get() returns -EPROBE_DEFER when the clock provider has not
registered yet.
The driver core only retries a probe that returns -EPROBE_DEFER. If the
clock provider or interrupt controller registers after this driver
probes, would the CAN interface ever bind? Would it be better to return
PTR_ERR(clk) and irq instead?
[ ... ]
> @@ -908,6 +908,8 @@ static int sun4ican_probe(struct platform_device *pdev)
>
> exit_free:
> free_candev(dev);
> +exit_put_clk:
> + clk_put(clk);
> exit:
> return err;
> }
[Severity: High]
This covers the probe error paths. Does the clock reference from
of_clk_get() still leak when the device is removed?
On a successful probe the reference is stored in priv->clk:
priv->clk = clk;
sun4ican_remove() never drops it:
static void sun4ican_remove(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
unregister_netdev(dev);
free_candev(dev);
}
free_candev() calls free_netdev(), which frees the private area that
holds priv->clk. After that, nothing is left to release the reference.
The clk_put() added here is the only one in the file.
So each successful probe followed by a module unload or sysfs unbind
would still leak the struct clk. It would also leave the clk_core
refcount and the clock provider's module reference held for good.
Would switching to devm_clk_get(&pdev->dev, NULL) be simpler? It would
handle both the probe error paths and the remove path, and the
exit_put_clk label would no longer be needed.
If the manual clk_put() is kept, sun4ican_remove() would need to read
priv->clk before calling free_candev(), because priv lives inside the
netdev allocation.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009134323.64064-2-mkl%40pengutronix.de
Re: [PATCH net-next 03/37] can: convert unreliable ARPHRD_CAN type checks to robust can_get_ml_priv()
Author: Marc Kleine-Budde
Date: Mon, 12 Oct 2026 13:09
Date: Mon, 12 Oct 2026 13:09
127 lines
12644 bytes
12644 bytes
--r6uis5calrxcbkl3
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Subject: Re: [PATCH net-next 03/37] can: convert unreliable ARPHRD_CAN type
checks to robust can_get_ml_priv()
MIME-Version: 1.0
On 12.10.2026 14:58:09, Oliver Hartkopp wrote:
>
>
> On 10.10.26 16:02, netdev-bot+sashiko@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found more severe
> > issue(s) in other patches of this series. This mail is only an FYI, in =
case
> > you want to address the nit picks below when you respin.
> >
> > Low priority / nit picks for your consideration:
> >
> > - [Low] The commit message calls the change a conversion of 'unreliable'
> > ARPHRD_CAN checks to 'robust' can_get_ml_priv() checks.
> >
> > Pre-existing issues:
> > - [Medium] This problem wasn't introduced by this patch, but isotp_bind=
()
> > in net/can/isotp.c ignores the return values of both can_rx_register=
()=E2=80=A6
> >
> > --
> >
> > can: convert unreliable ARPHRD_CAN type checks to robust can_get_ml_pri=
v()
> >
> > This patch replaces the remaining dev->type !=3D ARPHRD_CAN checks in
> > af_can, bcm, gw, isotp and raw with can_get_ml_priv(). The reason given=
is
> > that TUNSETLINK can switch a down TUN/TAP device to ARPHRD_CAN while its
> > ml_priv stays NULL.
> >
> > Link: https://patch.msgid.link/20261009121115.61012-1-socketcan@hartkop=
p.net
> >
> > > diff --git a/net/can/af_can.c b/net/can/af_can.c
> > > index 34fe3b28d576f..dc27ace43719d 100644
> > > --- a/net/can/af_can.c
> > > +++ b/net/can/af_can.c
> >
> > [ ... ]
> >
> > > @@ -519,7 +519,7 @@ void can_rx_unregister(struct net *net, struct ne=
t_device *dev, canid_t can_id,
> > > struct can_rcv_lists_stats *rcv_lists_stats =3D net->can.rcv_lists=
_stats;
> > > struct can_dev_rcv_lists *dev_rcv_lists;
> > > - if (dev && dev->type !=3D ARPHRD_CAN)
> > > + if (dev && !can_get_ml_priv(dev))
> > > return;
> >
> > [Severity: Low]
> > The commit message describes this change as replacing "unreliable" chec=
ks
> > with "robust" ones. Should it also say that the change closes a NULL
> > pointer dereference that a user can trigger?
> >
> > Before this patch, the sequence looks like this:
> >
> > ioctl(TUNSETLINK, ARPHRD_CAN) on a down tun device
> > tun->dev->type =3D (int) arg; /* ml_priv stays NULL */
> > isotp_bind()
> > old dev->type !=3D ARPHRD_CAN check passes
> > can_rx_register() returns -ENODEV, return value ignored
> > so->bound =3D 1; so->dev =3D dev;
> > isotp_release() or isotp_notify()
> > can_rx_unregister(net, so->dev, ...)
> > old dev->type !=3D ARPHRD_CAN guard passes
> > can_dev_rcv_lists_find()
> > can_ml =3D can_get_ml_priv(dev); /* NULL */
> > return &can_ml->dev_rcv_lists;
> > hlist_for_each_entry_rcu() walks the near-NULL pointer
> >
> > dev_rcv_lists sits at offset 0 of struct can_ml_priv, so the returned
> > pointer is near-NULL and the list walk oopses.
> >
> > Triggering this only requires owning a tun device, or CAP_NET_ADMIN ins=
ide
> > an unprivileged user namespace.
> >
> > The patch carries a Cc: stable tag. Could the message name the oops in
> > can_rx_unregister() (reached through isotp_release() or isotp_notify())=
and
> > the privilege needed to trigger it?
>
> Hi Marc,
>
> do you want me to rephrase the commit message?
>
> The referenced "Fixes" commit from Oleksij
> 4e096a18867a5a989b ("net: introduce CAN specific pointer in the struct
> net_device") was introduced in Linux 5.12 but is available in stable 5.10.
please go ahead!
regards,
Marc
pw-bot: cr
--=20
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
--r6uis5calrxcbkl3
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQSl+MghEFFAdY3pYJLMOmT6rpmt0gUCaszcDgAKCRDMOmT6rpmt
0mSsAQDuelT0HxUcHTamM4nKWPRFKQrKACOMxAknDjR1uiVF4wEA4BFVdRRdc17N
7GSZTUmkyKEIlaff9JGFWtU8UCqdoAM=
=+AaR
-----END PGP SIGNATURE-----
--r6uis5calrxcbkl3--
Page 2 of 2 • 58 total messages
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