can: gw: syncronize rcu operations before removing gw job entry
Subsystems (2)
Oliver Hartkopp
maintainerPATCH 1/1 can: gw: syncronize rcu operations before removing gw job entry
can_can_gw_rcv() is called under RCU protection, so after calling can_rx_unregister, we may call synchronize_rcu in order to wait for any RCU read-side critical sections to finish before removing the kmem_cache entry with the referenced gw job entry.
Signed-off-by Oliver Hartkopp <[email protected]>
--- net/can/gw.c | 3 +++ 1 file changed, 3 insertions(+)
net/can/gw.c +3 -0
@@ -594,10 +594,11 @@ static int cgw_notifier(struct notifier_block *nb,hlist_for_each_entry_safe (gwj, nx, &net->can.cgw_list, list) {if (gwj->src.dev == dev || gwj->dst.dev == dev) {hlist_del (&gwj->list);cgw_unregister_filter (net, gwj); +synchronize_rcu ();kmem_cache_free (cgw_cache, gwj); } } }
@@ -1152,10 +1153,11 @@ static void cgw_remove_all_jobs(struct net *net)ASSERT_RTNL ();hlist_for_each_entry_safe (gwj, nx, &net->can.cgw_list, list) {hlist_del (&gwj->list);cgw_unregister_filter (net, gwj); +synchronize_rcu ();kmem_cache_free (cgw_cache, gwj); } } static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1220,10 +1222,11 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh,if (memcmp (&gwj->ccgw, &ccgw,sizeof (ccgw)))continue ;hlist_del (&gwj->list);cgw_unregister_filter (net, gwj); +synchronize_rcu ();kmem_cache_free (cgw_cache, gwj); err =0 ;break ; }
Signature · 1 line
2.30.2
Marc Kleine-Budde
maintainerQuoted 6 lines · Oliver Hartkopp
can_can_gw_rcv()is called under RCU protection, so after callingcan_rx_unregister, we may callsynchronize_rcuin order to wait for any RCU read-side critical sections to finish before removing thekmem_cacheentry with the referenced gw job entry.Signed-off-by Oliver Hartkopp <[email protected]>
Applied to linux-can/testing.
Thanks,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |