@@ -323,6 +323,16 @@ static int nft_netdev_register_hooks(struct net *net,
323323 return err ;
324324}
325325
326+ static void nft_netdev_hook_free (struct nft_hook * hook )
327+ {
328+ kfree (hook );
329+ }
330+
331+ static void nft_netdev_hook_free_rcu (struct nft_hook * hook )
332+ {
333+ kfree_rcu (hook , rcu );
334+ }
335+
326336static void nft_netdev_unregister_hooks (struct net * net ,
327337 struct list_head * hook_list ,
328338 bool release_netdev )
@@ -333,7 +343,7 @@ static void nft_netdev_unregister_hooks(struct net *net,
333343 nf_unregister_net_hook (net , & hook -> ops );
334344 if (release_netdev ) {
335345 list_del (& hook -> list );
336- kfree_rcu (hook , rcu );
346+ nft_netdev_hook_free_rcu (hook );
337347 }
338348 }
339349}
@@ -2253,7 +2263,7 @@ void nf_tables_chain_destroy(struct nft_chain *chain)
22532263 list_for_each_entry_safe (hook , next ,
22542264 & basechain -> hook_list , list ) {
22552265 list_del_rcu (& hook -> list );
2256- kfree_rcu (hook , rcu );
2266+ nft_netdev_hook_free_rcu (hook );
22572267 }
22582268 }
22592269 module_put (basechain -> type -> owner );
@@ -2345,7 +2355,7 @@ static int nf_tables_parse_netdev_hooks(struct net *net,
23452355 }
23462356 if (nft_hook_list_find (hook_list , hook )) {
23472357 NL_SET_BAD_ATTR (extack , tmp );
2348- kfree (hook );
2358+ nft_netdev_hook_free (hook );
23492359 err = - EEXIST ;
23502360 goto err_hook ;
23512361 }
@@ -2363,7 +2373,7 @@ static int nf_tables_parse_netdev_hooks(struct net *net,
23632373err_hook :
23642374 list_for_each_entry_safe (hook , next , hook_list , list ) {
23652375 list_del (& hook -> list );
2366- kfree (hook );
2376+ nft_netdev_hook_free (hook );
23672377 }
23682378 return err ;
23692379}
@@ -2506,7 +2516,7 @@ static void nft_chain_release_hook(struct nft_chain_hook *hook)
25062516
25072517 list_for_each_entry_safe (h , next , & hook -> list , list ) {
25082518 list_del (& h -> list );
2509- kfree (h );
2519+ nft_netdev_hook_free (h );
25102520 }
25112521 module_put (hook -> type -> owner );
25122522}
@@ -2795,7 +2805,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
27952805
27962806 if (nft_hook_list_find (& basechain -> hook_list , h )) {
27972807 list_del (& h -> list );
2798- kfree (h );
2808+ nft_netdev_hook_free (h );
27992809 }
28002810 }
28012811 } else {
@@ -2916,7 +2926,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
29162926 if (unregister )
29172927 nf_unregister_net_hook (ctx -> net , & h -> ops );
29182928 list_del (& h -> list );
2919- kfree_rcu ( h , rcu );
2929+ nft_netdev_hook_free_rcu ( h );
29202930 }
29212931 module_put (hook .type -> owner );
29222932 }
@@ -8907,7 +8917,7 @@ static void __nft_unregister_flowtable_net_hooks(struct net *net,
89078917 FLOW_BLOCK_UNBIND );
89088918 if (release_netdev ) {
89098919 list_del (& hook -> list );
8910- kfree_rcu (hook , rcu );
8920+ nft_netdev_hook_free_rcu (hook );
89118921 }
89128922 }
89138923}
@@ -8965,7 +8975,7 @@ static int nft_register_flowtable_net_hooks(struct net *net,
89658975
89668976 nft_unregister_flowtable_hook (net , flowtable , hook );
89678977 list_del_rcu (& hook -> list );
8968- kfree_rcu (hook , rcu );
8978+ nft_netdev_hook_free_rcu (hook );
89698979 }
89708980
89718981 return err ;
@@ -8977,7 +8987,7 @@ static void nft_hooks_destroy(struct list_head *hook_list)
89778987
89788988 list_for_each_entry_safe (hook , next , hook_list , list ) {
89798989 list_del_rcu (& hook -> list );
8980- kfree_rcu (hook , rcu );
8990+ nft_netdev_hook_free_rcu (hook );
89818991 }
89828992}
89838993
@@ -9001,7 +9011,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
90019011 list_for_each_entry_safe (hook , next , & flowtable_hook .list , list ) {
90029012 if (nft_hook_list_find (& flowtable -> hook_list , hook )) {
90039013 list_del (& hook -> list );
9004- kfree (hook );
9014+ nft_netdev_hook_free (hook );
90059015 }
90069016 }
90079017
@@ -9048,7 +9058,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
90489058 if (unregister )
90499059 nft_unregister_flowtable_hook (ctx -> net , flowtable , hook );
90509060 list_del_rcu (& hook -> list );
9051- kfree_rcu (hook , rcu );
9061+ nft_netdev_hook_free_rcu (hook );
90529062 }
90539063
90549064 return err ;
@@ -9194,7 +9204,7 @@ static void nft_flowtable_hook_release(struct nft_flowtable_hook *flowtable_hook
91949204
91959205 list_for_each_entry_safe (this , next , & flowtable_hook -> list , list ) {
91969206 list_del (& this -> list );
9197- kfree (this );
9207+ nft_netdev_hook_free (this );
91989208 }
91999209}
92009210
@@ -9557,7 +9567,7 @@ static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable)
95579567 flowtable -> data .type -> free (& flowtable -> data );
95589568 list_for_each_entry_safe (hook , next , & flowtable -> hook_list , list ) {
95599569 list_del_rcu (& hook -> list );
9560- kfree_rcu (hook , rcu );
9570+ nft_netdev_hook_free_rcu (hook );
95619571 }
95629572 kfree (flowtable -> name );
95639573 module_put (flowtable -> data .type -> owner );
0 commit comments