Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: sched: call tcf_ct_params_free to free params in tcf_ct_init

This patch is to make the err path simple by calling tcf_ct_params_free(),
so that it won't cause problems when more members are added into param and
need freeing on the err path.

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Xin Long and committed by
Paolo Abeni
19138941 f96cba2e

+18 -17
+18 -17
net/sched/act_ct.c
··· 345 345 module_put(THIS_MODULE); 346 346 } 347 347 348 - static void tcf_ct_flow_table_put(struct tcf_ct_params *params) 348 + static void tcf_ct_flow_table_put(struct tcf_ct_flow_table *ct_ft) 349 349 { 350 - struct tcf_ct_flow_table *ct_ft = params->ct_ft; 351 - 352 - if (refcount_dec_and_test(&params->ct_ft->ref)) { 350 + if (refcount_dec_and_test(&ct_ft->ref)) { 353 351 rhashtable_remove_fast(&zones_ht, &ct_ft->node, zones_params); 354 352 INIT_RCU_WORK(&ct_ft->rwork, tcf_ct_flow_table_cleanup_work); 355 353 queue_rcu_work(act_ct_wq, &ct_ft->rwork); ··· 830 832 return err; 831 833 } 832 834 833 - static void tcf_ct_params_free(struct rcu_head *head) 835 + static void tcf_ct_params_free(struct tcf_ct_params *params) 834 836 { 835 - struct tcf_ct_params *params = container_of(head, 836 - struct tcf_ct_params, rcu); 837 - 838 - tcf_ct_flow_table_put(params); 839 - 837 + if (params->ct_ft) 838 + tcf_ct_flow_table_put(params->ct_ft); 840 839 if (params->tmpl) 841 840 nf_ct_put(params->tmpl); 842 841 kfree(params); 842 + } 843 + 844 + static void tcf_ct_params_free_rcu(struct rcu_head *head) 845 + { 846 + struct tcf_ct_params *params; 847 + 848 + params = container_of(head, struct tcf_ct_params, rcu); 849 + tcf_ct_params_free(params); 843 850 } 844 851 845 852 #if IS_ENABLED(CONFIG_NF_NAT) ··· 1393 1390 1394 1391 err = tcf_ct_flow_table_get(net, params); 1395 1392 if (err) 1396 - goto cleanup_params; 1393 + goto cleanup; 1397 1394 1398 1395 spin_lock_bh(&c->tcf_lock); 1399 1396 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); ··· 1404 1401 if (goto_ch) 1405 1402 tcf_chain_put_by_act(goto_ch); 1406 1403 if (params) 1407 - call_rcu(&params->rcu, tcf_ct_params_free); 1404 + call_rcu(&params->rcu, tcf_ct_params_free_rcu); 1408 1405 1409 1406 return res; 1410 1407 1411 - cleanup_params: 1412 - if (params->tmpl) 1413 - nf_ct_put(params->tmpl); 1414 1408 cleanup: 1415 1409 if (goto_ch) 1416 1410 tcf_chain_put_by_act(goto_ch); 1417 - kfree(params); 1411 + if (params) 1412 + tcf_ct_params_free(params); 1418 1413 tcf_idr_release(*a, bind); 1419 1414 return err; 1420 1415 } ··· 1424 1423 1425 1424 params = rcu_dereference_protected(c->params, 1); 1426 1425 if (params) 1427 - call_rcu(&params->rcu, tcf_ct_params_free); 1426 + call_rcu(&params->rcu, tcf_ct_params_free_rcu); 1428 1427 } 1429 1428 1430 1429 static int tcf_ct_dump_key_val(struct sk_buff *skb,