lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <542983D0.8060701@cogentembedded.com>
Date:	Mon, 29 Sep 2014 20:07:44 +0400
From:	Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To:	Pablo Neira Ayuso <pablo@...filter.org>,
	netfilter-devel@...r.kernel.org
CC:	davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH 30/34] net/netfilter/x_tables.c: use __seq_open_private()

Hello.

On 09/29/2014 04:39 PM, Pablo Neira Ayuso wrote:

> From: Rob Jones <rob.jones@...ethink.co.uk>

> Reduce boilerplate code by using __seq_open_private() instead of seq_open()
> in xt_match_open() and xt_target_open().

> Signed-off-by: Rob Jones <rob.jones@...ethink.co.uk>
> Signed-off-by: Pablo Neira Ayuso <pablo@...filter.org>
> ---
>   net/netfilter/x_tables.c |   30 ++++--------------------------
>   1 file changed, 4 insertions(+), 26 deletions(-)

> diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> index 272ae4d..133eb47 100644
> --- a/net/netfilter/x_tables.c
> +++ b/net/netfilter/x_tables.c
> @@ -1101,22 +1101,11 @@ static const struct seq_operations xt_match_seq_ops = {
>
>   static int xt_match_open(struct inode *inode, struct file *file)
>   {
> -	struct seq_file *seq;
>   	struct nf_mttg_trav *trav;
> -	int ret;
> -

    Please don't remove this empty line after declaration.

> -	trav = kmalloc(sizeof(*trav), GFP_KERNEL);
> -	if (trav == NULL)
> +	trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav));
> +	if (!trav)
>   		return -ENOMEM;
>
> -	ret = seq_open(file, &xt_match_seq_ops);
> -	if (ret < 0) {
> -		kfree(trav);
> -		return ret;
> -	}
> -
> -	seq = file->private_data;
> -	seq->private = trav;
>   	trav->nfproto = (unsigned long)PDE_DATA(inode);
>   	return 0;
>   }
> @@ -1165,22 +1154,11 @@ static const struct seq_operations xt_target_seq_ops = {
>
>   static int xt_target_open(struct inode *inode, struct file *file)
>   {
> -	struct seq_file *seq;
>   	struct nf_mttg_trav *trav;
> -	int ret;
> -

    Likewise.

> -	trav = kmalloc(sizeof(*trav), GFP_KERNEL);
> -	if (trav == NULL)
> +	trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav));
> +	if (!trav)
>   		return -ENOMEM;

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ