Skip to content

Commit 1745234

Browse files
tammeladavem330
authored andcommitted
net: rtnl: use rcu_replace_pointer_rtnl in rtnl_unregister_*
With the introduction of the rcu_replace_pointer_rtnl helper, cleanup the rtnl_unregister_* functions to use the helper instead of open coding it. Signed-off-by: Pedro Tammela <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 32da0f0 commit 1745234

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

net/core/rtnetlink.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ int rtnl_unregister(int protocol, int msgtype)
342342
return -ENOENT;
343343
}
344344

345-
link = rtnl_dereference(tab[msgindex]);
346-
RCU_INIT_POINTER(tab[msgindex], NULL);
345+
link = rcu_replace_pointer_rtnl(tab[msgindex], NULL);
347346
rtnl_unlock();
348347

349348
kfree_rcu(link, rcu);
@@ -368,18 +367,13 @@ void rtnl_unregister_all(int protocol)
368367
BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
369368

370369
rtnl_lock();
371-
tab = rtnl_dereference(rtnl_msg_handlers[protocol]);
370+
tab = rcu_replace_pointer_rtnl(rtnl_msg_handlers[protocol], NULL);
372371
if (!tab) {
373372
rtnl_unlock();
374373
return;
375374
}
376-
RCU_INIT_POINTER(rtnl_msg_handlers[protocol], NULL);
377375
for (msgindex = 0; msgindex < RTM_NR_MSGTYPES; msgindex++) {
378-
link = rtnl_dereference(tab[msgindex]);
379-
if (!link)
380-
continue;
381-
382-
RCU_INIT_POINTER(tab[msgindex], NULL);
376+
link = rcu_replace_pointer_rtnl(tab[msgindex], NULL);
383377
kfree_rcu(link, rcu);
384378
}
385379
rtnl_unlock();

0 commit comments

Comments
 (0)