can: statistics: add missing atomic access in hot path
Subsystems (2)
Oliver Hartkopp
maintainerPATCH v2 1/1 can: statistics: add missing atomic access in hot path
Commit 80b5f90158d1 ("can: statistics: use atomic access in hot path") fixed a KCSAN issue in can_receive() but missed to convert the 'matches' variable used in can_rcv_filter().
Fixes 80b5f90158d1 ("can: statistics: use atomic access in hot path")
Signed-off-by Oliver Hartkopp <[email protected]>
--- net/can/af_can.c | 4 ++-- net/can/af_can.h | 2 +- net/can/proc.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)
net/can/af_can.c +2 -2
@@ -467,11 +467,11 @@ int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id, dev_rcv_lists =can_dev_rcv_lists_find (net, dev); rcv_list =can_rcv_list_find (&can_id, &mask, dev_rcv_lists); rcv->can_id = can_id; rcv->mask = mask; - rcv->matches =0 ; +atomic_long_set (&rcv->matches,0 ); rcv->func = func; rcv->data = data; rcv->ident = ident; rcv->sk = sk;
@@ -571,11 +571,11 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,EXPORT_SYMBOL (can_rx_unregister);static inline void deliver (struct sk_buff *skb,struct receiver *rcv) { rcv->func (skb, rcv->data); - rcv->matches++; +atomic_long_inc (&rcv->matches); }static int can_rcv_filter (struct can_dev_rcv_lists *dev_rcv_lists,struct sk_buff *skb) {struct receiver *rcv;
net/can/af_can.h +1 -1
@@ -50,11 +50,11 @@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;struct sock *sk;struct rcu_head rcu;
net/can/proc.c +2 -1
@@ -194,11 +194,12 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list,char *fmt = (r->can_id &CAN_EFF_FLAG )?" %-5s %08x %08x %pK %pK %8ld %s\n" :" %-5s %03x %08x %pK %pK %8ld %s\n" ;seq_printf (m, fmt,DNAME (dev), r->can_id, r->mask, - r->func, r->data, r->matches, r->ident); + r->func, r->data,atomic_long_read (&r->matches), + r->ident); } }static void can_print_recv_banner (struct seq_file *m) {
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerQuoted 6 lines · Oliver Hartkopp
Commit
80b5f90158d1("can: statistics: use atomic access in hot path") fixed a KCSAN issue incan_receive()but missed to convert the 'matches' variable used incan_rcv_filter().Fixes 80b5f90158d1 ("can: statistics: use atomic access in hot path")Signed-off-by Oliver Hartkopp <[email protected]>
Added to linux-can.
regards,
Marc
Signature · 4 lines
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 |