mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
netfilter: nf_tables: Unconditionally allocate nft_obj_filter
Prep work for moving the filter into struct netlink_callback's scratch area. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
ff16111cc1
commit
4279cc60b3
1 changed files with 15 additions and 21 deletions
|
@ -7717,11 +7717,9 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
|||
goto cont;
|
||||
if (idx < s_idx)
|
||||
goto cont;
|
||||
if (filter && filter->table &&
|
||||
strcmp(filter->table, table->name))
|
||||
if (filter->table && strcmp(filter->table, table->name))
|
||||
goto cont;
|
||||
if (filter &&
|
||||
filter->type != NFT_OBJECT_UNSPEC &&
|
||||
if (filter->type != NFT_OBJECT_UNSPEC &&
|
||||
obj->ops->type->type != filter->type)
|
||||
goto cont;
|
||||
|
||||
|
@ -7756,23 +7754,21 @@ static int nf_tables_dump_obj_start(struct netlink_callback *cb)
|
|||
const struct nlattr * const *nla = cb->data;
|
||||
struct nft_obj_filter *filter = NULL;
|
||||
|
||||
if (nla[NFTA_OBJ_TABLE] || nla[NFTA_OBJ_TYPE]) {
|
||||
filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
|
||||
if (!filter)
|
||||
filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
|
||||
if (!filter)
|
||||
return -ENOMEM;
|
||||
|
||||
if (nla[NFTA_OBJ_TABLE]) {
|
||||
filter->table = nla_strdup(nla[NFTA_OBJ_TABLE], GFP_ATOMIC);
|
||||
if (!filter->table) {
|
||||
kfree(filter);
|
||||
return -ENOMEM;
|
||||
|
||||
if (nla[NFTA_OBJ_TABLE]) {
|
||||
filter->table = nla_strdup(nla[NFTA_OBJ_TABLE], GFP_ATOMIC);
|
||||
if (!filter->table) {
|
||||
kfree(filter);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (nla[NFTA_OBJ_TYPE])
|
||||
filter->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
|
||||
}
|
||||
|
||||
if (nla[NFTA_OBJ_TYPE])
|
||||
filter->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
|
||||
|
||||
cb->data = filter;
|
||||
return 0;
|
||||
}
|
||||
|
@ -7781,10 +7777,8 @@ static int nf_tables_dump_obj_done(struct netlink_callback *cb)
|
|||
{
|
||||
struct nft_obj_filter *filter = cb->data;
|
||||
|
||||
if (filter) {
|
||||
kfree(filter->table);
|
||||
kfree(filter);
|
||||
}
|
||||
kfree(filter->table);
|
||||
kfree(filter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue