提交 93fac10b 编写于 作者: L Liping Zhang 提交者: Pablo Neira Ayuso

netfilter: nfnetlink: use list_for_each_entry_safe to delete all objects

cttimeout and acct objects are deleted from the list while traversing
it, so use list_for_each_entry is unsafe here.
Signed-off-by: NLiping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 89e1f6d2
...@@ -343,12 +343,12 @@ static int nfnl_acct_del(struct net *net, struct sock *nfnl, ...@@ -343,12 +343,12 @@ static int nfnl_acct_del(struct net *net, struct sock *nfnl,
struct sk_buff *skb, const struct nlmsghdr *nlh, struct sk_buff *skb, const struct nlmsghdr *nlh,
const struct nlattr * const tb[]) const struct nlattr * const tb[])
{ {
char *acct_name; struct nf_acct *cur, *tmp;
struct nf_acct *cur;
int ret = -ENOENT; int ret = -ENOENT;
char *acct_name;
if (!tb[NFACCT_NAME]) { if (!tb[NFACCT_NAME]) {
list_for_each_entry(cur, &net->nfnl_acct_list, head) list_for_each_entry_safe(cur, tmp, &net->nfnl_acct_list, head)
nfnl_acct_try_del(cur); nfnl_acct_try_del(cur);
return 0; return 0;
......
...@@ -350,12 +350,13 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl, ...@@ -350,12 +350,13 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl,
const struct nlmsghdr *nlh, const struct nlmsghdr *nlh,
const struct nlattr * const cda[]) const struct nlattr * const cda[])
{ {
struct ctnl_timeout *cur; struct ctnl_timeout *cur, *tmp;
int ret = -ENOENT; int ret = -ENOENT;
char *name; char *name;
if (!cda[CTA_TIMEOUT_NAME]) { if (!cda[CTA_TIMEOUT_NAME]) {
list_for_each_entry(cur, &net->nfct_timeout_list, head) list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list,
head)
ctnl_timeout_try_del(net, cur); ctnl_timeout_try_del(net, cur);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册