Re: [PATCH v3 3/3] can: statistics: add missing atomic access in hot path

From: Marc Kleine-Budde

Date: Mon Mar 02 2026 - 05:31:00 EST


The nipa/ai-review bot found these problems:

| https://netdev-ai.bots.linux.dev/ai-review.html?id=873e6dfb-7d8e-4f4d-98ef-a89fcedb701a

commit 083c819fbd59ad774cbf0662b6530ae8cf926328
Author: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>

can: statistics: add missing atomic access in hot path

This patch converts the matches field in struct receiver from unsigned
long to atomic_long_t to fix a KCSAN race that was missed by commit
80b5f90158d1.

> diff --git a/net/can/af_can.h b/net/can/af_can.h
> --- a/net/can/af_can.h
> +++ b/net/can/af_can.h
> @@ -52,7 +52,7 @@ struct receiver {
> struct hlist_node list;
> canid_t can_id;
> canid_t mask;
> - unsigned long matches;
> + atomic_long_t matches;
> void (*func)(struct sk_buff *skb, void *data);
> void *data;
> char *ident;

With this type change, is can_print_rcvlist() in net/can/proc.c also
missing a conversion? It still accesses r->matches directly:

net/can/proc.c:can_print_rcvlist() {
...
seq_printf(m, fmt, DNAME(dev), r->can_id, r->mask,
r->func, r->data, r->matches, r->ident);
...
}

Should this be atomic_long_read(&r->matches) to match the other
conversion sites?

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |

Attachment: signature.asc
Description: PGP signature