diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 388f5773b88d..3a807ae69a12 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -760,6 +760,12 @@ static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh, { struct nh_grp_entry *nhge, *tmp; + /* If there is nothing to do, let's avoid the costly call to + * synchronize_net() + */ + if (list_empty(&nh->grp_list)) + return; + list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) remove_nh_grp_entry(net, nhge, nlinfo);