@@ -1368,13 +1368,12 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
if (nlh->nlmsg_flags & NLM_F_EXCL)
return -EEXIST;
- if (nlh->nlmsg_flags & NLM_F_REPLACE) {
+ if (nlh->nlmsg_flags & NLM_F_REPLACE)
old_rule = rule;
- rule = NULL;
- } else
+ else
return -EOPNOTSUPP;
} else {
- if (!create)
+ if (!create || nlh->nlmsg_flags & NLM_F_REPLACE)
return -EINVAL;
handle = nf_tables_alloc_handle(table);
}
@@ -1415,9 +1414,6 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
}
if (nlh->nlmsg_flags & NLM_F_REPLACE) {
- if (old_rule == NULL)
- goto err2;
-
list_replace_rcu(&old_rule->list, &rule->list);
nf_tables_rule_notify(skb, nlh, table, chain, old_rule,