From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: Wei Yongjun <yjwei@cn.fujitsu.com>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [PATCH] ipv6: Remove some pointless conditionals before kfree_skb()
Date: Tue, 24 Feb 2009 17:33:37 +0800 [thread overview]
Message-ID: <49A3BEF1.4030802@cn.fujitsu.com> (raw)
In-Reply-To: <49A3A59D.9090102@cn.fujitsu.com>
Wei Yongjun wrote:
> Remove some pointless conditionals before kfree_skb().
>
> The semantic match that finds the problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
>
> // <smpl>
> @@
> expression E;
> @@
> - if (E)
> - kfree_skb(E);
> + kfree_skb(E);
> // </smpl>
I think kfree_skb() suppose that you have handled NULL pointer
because it uses `unlikely` to check the pointer.
So I don't think these conditions are pointless...
437 void kfree_skb(struct sk_buff *skb)
438 {
439 if (unlikely(!skb))
440 return;
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
> net/ipv6/ipv6_sockglue.c | 3 +--
> net/ipv6/tcp_ipv6.c | 6 ++----
> 2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index 40f3246..d31df0f 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -218,8 +218,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
> if (opt)
> sock_kfree_s(sk, opt, opt->tot_len);
> pktopt = xchg(&np->pktoptions, NULL);
> - if (pktopt)
> - kfree_skb(pktopt);
> + kfree_skb(pktopt);
>
> sk->sk_destruct = inet_sock_destruct;
> /*
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index e5b85d4..273a5dd 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -533,8 +533,7 @@ static inline void syn_flood_warning(struct sk_buff *skb)
>
> static void tcp_v6_reqsk_destructor(struct request_sock *req)
> {
> - if (inet6_rsk(req)->pktopts)
> - kfree_skb(inet6_rsk(req)->pktopts);
> + kfree_skb(inet6_rsk(req)->pktopts);
> }
>
> #ifdef CONFIG_TCP_MD5SIG
> @@ -1611,8 +1610,7 @@ ipv6_pktoptions:
> }
> }
>
> - if (opt_skb)
> - kfree_skb(opt_skb);
> + kfree_skb(opt_skb);
> return 0;
> }
>
--
Regards
Yang Hongyang
next prev parent reply other threads:[~2009-02-24 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 7:45 [PATCH] ipv6: Remove some pointless conditionals before kfree_skb() Wei Yongjun
2009-02-24 9:33 ` Yang Hongyang [this message]
2009-02-24 9:47 ` Herbert Xu
2009-02-24 9:54 ` Yang Hongyang
2009-02-24 9:55 ` Herbert Xu
2009-02-25 7:38 ` David Miller
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=49A3BEF1.4030802@cn.fujitsu.com \
--to=yanghy@cn.fujitsu.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=yjwei@cn.fujitsu.com \
/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).