mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	laforge@netfilter.org, Jesper Juhl <juhl-lkml@dif.dk>
Subject: Re: Shouldn't we be using alloc_skb/kfree_skb in net/ipv4/netfilter/ipt_recent.c::ip_recent_ctrl ?
Date: Thu, 16 Jun 2005 18:33:57 -0400	[thread overview]
Message-ID: <20050616223357.GR30011@ns.snowman.net> (raw)
In-Reply-To: <Pine.LNX.4.62.0506170025140.2477@dragon.hyggekrogen.localhost>

[-- Attachment #1: Type: text/plain, Size: 1813 bytes --]

Greetings,

* Jesper Juhl (juhl-lkml@dif.dk) wrote:
> I was just grep'ing through the source looking for places where skb's 
> might be freed by plain kfree() and, amongst other things, I noticed 
> net/ipv4/netfilter/ipt_recent.c::ip_recent_ctrl, where a struct sk_buff* 
> is defined and then storage for it is allocated with kmalloc() and freed 
> with kfree(), and I'm wondering if we shouldn't be using 
> alloc_skb/kfree_skb instead (as pr the patch below)? Or is there some good 
> reason for doing it the way it's currently done?

  This sounds reasonable to me.  I'm about 99% sure I just based that
  usage off some other usage in the kernel I found back when I
  originally wrote the module.

  So, for what it's worth I suppose (if anything, and I'm probably not
  doing it right anyway)-

Signed-off-by: Stephen Frost <sfrost@snowman.net>

		Enjoy,

			Stephen

> Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
> ---
> 
>  net/ipv4/netfilter/ipt_recent.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> --- linux-2.6.12-rc6-mm1-orig/net/ipv4/netfilter/ipt_recent.c	2005-06-12 15:58:58.000000000 +0200
> +++ linux-2.6.12-rc6-mm1/net/ipv4/netfilter/ipt_recent.c	2005-06-16 23:41:55.000000000 +0200
> @@ -303,7 +303,7 @@ static int ip_recent_ctrl(struct file *f
>  	strncpy(info->name,curr_table->name,IPT_RECENT_NAME_LEN);
>  	info->name[IPT_RECENT_NAME_LEN-1] = '\0';
>  
> -	skb = kmalloc(sizeof(struct sk_buff),GFP_KERNEL);
> +	skb = alloc_skb(sizeof(struct sk_buff),GFP_KERNEL);
>  	if (!skb) {
>  		used = -ENOMEM;
>  		goto out_free_info;
> @@ -322,7 +322,7 @@ static int ip_recent_ctrl(struct file *f
>  
>  	kfree(skb->nh.iph);
>  out_free_skb:
> -	kfree(skb);
> +	kfree_skb(skb);
>  out_free_info:
>  	kfree(info);
>  
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-06-16 22:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-16 22:36 Jesper Juhl
2005-06-16 22:33 ` Stephen Frost [this message]
2005-06-16 22:48 ` David S. Miller
2005-06-16 22:53   ` Jesper Juhl
2005-06-17  2:31   ` Stephen Frost

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=20050616223357.GR30011@ns.snowman.net \
    --to=sfrost@snowman.net \
    --cc=jesper.juhl@gmail.com \
    --cc=juhl-lkml@dif.dk \
    --cc=laforge@netfilter.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®