From: Eric Dumazet <eric.dumazet@gmail.com>
To: jovi zhang <bookjovi@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Johannes Berg <johannes.berg@intel.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Alexey Dobriyan <adobriyan@openvz.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] netlink: Fix kfree NULL pointer
Date: Wed, 08 Sep 2010 07:19:45 +0200 [thread overview]
Message-ID: <1283923185.2634.772.camel@edumazet-laptop> (raw)
In-Reply-To: <AANLkTikp0m8cQYfEBHP_E8XpGZqdMj6Cr4M=aWCnei=X@mail.gmail.com>
Le mercredi 08 septembre 2010 à 13:13 +0800, jovi zhang a écrit :
> It will kfree NULL pointer if listeners is NULL. fix it.
>
> Signed-off-by: bookjovi@gmail.com
> net/netlink/af_netlink.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 980fe4a..1c7bf48 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -1532,8 +1532,10 @@ netlink_kernel_create(struct net *net, int
> unit, unsigned int groups,
> if (input)
> nlk_sk(sk)->netlink_rcv = input;
>
> - if (netlink_insert(sk, net, 0))
> + if (netlink_insert(sk, net, 0)) {
> + kfree(listeners);
> goto out_sock_release;
> + }
>
> nlk = nlk_sk(sk);
> nlk->flags |= NETLINK_KERNEL_SOCKET;
> @@ -1553,7 +1555,6 @@ netlink_kernel_create(struct net *net, int unit,
> unsigned int groups,
> return sk;
>
> out_sock_release:
> - kfree(listeners);
> netlink_kernel_release(sk);
> return NULL;
This patch is not needed
kfree(NULL) is legal
next parent reply other threads:[~2010-09-08 5:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTikp0m8cQYfEBHP_E8XpGZqdMj6Cr4M=aWCnei=X@mail.gmail.com>
2010-09-08 5:19 ` Eric Dumazet [this message]
2010-09-08 5:33 ` [PATCH] netlink: Fix kfree NULL pointer jovi zhang
2010-09-08 5:53 ` David Miller
2010-09-08 5:54 ` Eric W. Biederman
2010-09-08 5:55 ` Eric Dumazet
2010-09-08 6:14 ` jovi zhang
2010-09-08 5:13 jovi zhang
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=1283923185.2634.772.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=adobriyan@openvz.org \
--cc=bookjovi@gmail.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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