mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-08 10:25:20 +02:00
netfilter: nf_tables: nft_obj_filter fits into cb->ctx
[ Upstream commit5a893b9cdf
] No need to allocate it if one may just use struct netlink_callback's scratch area for it. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Stable-dep-of:bd662c4218
("netfilter: nf_tables: Add locking for NFT_MSG_GETOBJ_RESET requests") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
959c9bf85f
commit
f3b7dc8b6c
|
@ -7726,7 +7726,7 @@ struct nft_obj_dump_ctx {
|
||||||
static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
{
|
{
|
||||||
const struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
|
const struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
|
||||||
struct nft_obj_dump_ctx *ctx = cb->data;
|
struct nft_obj_dump_ctx *ctx = (void *)cb->ctx;
|
||||||
struct net *net = sock_net(skb->sk);
|
struct net *net = sock_net(skb->sk);
|
||||||
int family = nfmsg->nfgen_family;
|
int family = nfmsg->nfgen_family;
|
||||||
struct nftables_pernet *nft_net;
|
struct nftables_pernet *nft_net;
|
||||||
|
@ -7788,34 +7788,28 @@ cont:
|
||||||
|
|
||||||
static int nf_tables_dump_obj_start(struct netlink_callback *cb)
|
static int nf_tables_dump_obj_start(struct netlink_callback *cb)
|
||||||
{
|
{
|
||||||
|
struct nft_obj_dump_ctx *ctx = (void *)cb->ctx;
|
||||||
const struct nlattr * const *nla = cb->data;
|
const struct nlattr * const *nla = cb->data;
|
||||||
struct nft_obj_dump_ctx *ctx = NULL;
|
|
||||||
|
|
||||||
ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
|
BUILD_BUG_ON(sizeof(*ctx) > sizeof(cb->ctx));
|
||||||
if (!ctx)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if (nla[NFTA_OBJ_TABLE]) {
|
if (nla[NFTA_OBJ_TABLE]) {
|
||||||
ctx->table = nla_strdup(nla[NFTA_OBJ_TABLE], GFP_ATOMIC);
|
ctx->table = nla_strdup(nla[NFTA_OBJ_TABLE], GFP_ATOMIC);
|
||||||
if (!ctx->table) {
|
if (!ctx->table)
|
||||||
kfree(ctx);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (nla[NFTA_OBJ_TYPE])
|
if (nla[NFTA_OBJ_TYPE])
|
||||||
ctx->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
|
ctx->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
|
||||||
|
|
||||||
cb->data = ctx;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nf_tables_dump_obj_done(struct netlink_callback *cb)
|
static int nf_tables_dump_obj_done(struct netlink_callback *cb)
|
||||||
{
|
{
|
||||||
struct nft_obj_dump_ctx *ctx = cb->data;
|
struct nft_obj_dump_ctx *ctx = (void *)cb->ctx;
|
||||||
|
|
||||||
kfree(ctx->table);
|
kfree(ctx->table);
|
||||||
kfree(ctx);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user