From: Florian Westphal <fw@strlen.de>
To: "Jose M. Guisado Gomez" <guigom@riseup.net>
Cc: pablo@netfilter.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v3 nf-next] netfilter: nf_tables: add userdata attributes to nft_chain
Date: Wed, 23 Sep 2020 15:30:18 +0200 [thread overview]
Message-ID: <20200923133018.GA31471@breakpoint.cc> (raw)
In-Reply-To: <20200923131629.761-1-guigom@riseup.net>
Jose M. Guisado Gomez <guigom@riseup.net> wrote:
> Enables storing userdata for nft_chain. Field udata points to user data
> and udlen stores its length.
>
> Adds new attribute flag NFTA_CHAIN_USERDATA.
>
> Signed-off-by: Jose M. Guisado Gomez <guigom@riseup.net>
> ---
> + if (nla[NFTA_CHAIN_USERDATA]) {
> + udlen = nla_len(nla[NFTA_CHAIN_USERDATA]);
> + chain->udata = kzalloc(udlen, GFP_KERNEL);
> + if (chain->udata == NULL) {
> + err = -ENOMEM;
> + goto err_destroy_chain;
> + }
> +
> + nla_memcpy(chain->udata, nla[NFTA_CHAIN_USERDATA], udlen);
> + chain->udlen = udlen;
nit: You could use nla_memdup() instead of alloc+memcpy.
> -err2:
> +err_unregister_hook:
> nf_tables_unregister_hook(net, table, chain);
> -err1:
> +err_free_udata:
> + kfree(chain->udata);
> +err_destroy_chain:
> nf_tables_chain_destroy(ctx);
This frees ->udata on error. But what if the chain is added
successfully and then deleted at a later time?
Wouldn't it make more sense to only patch nf_tables_chain_destroy()
to handle both error and chain delete case?
prev parent reply other threads:[~2020-09-23 13:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 10:55 [PATCH v2 nf-next] netfilter: nf_tables: add userdata attributes to nft_chain Jose M. Guisado Gomez
2020-09-23 11:20 ` Pablo Neira Ayuso
2020-09-23 11:20 ` Pablo Neira Ayuso
2020-09-23 13:16 ` [PATCH v3 " Jose M. Guisado Gomez
2020-09-23 13:30 ` Florian Westphal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200923133018.GA31471@breakpoint.cc \
--to=fw@strlen.de \
--cc=guigom@riseup.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).