public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wan ZongShun <mcuos.com@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH] lib: fix a memory leak risk
Date: Fri, 04 Jun 2010 18:25:28 +0800	[thread overview]
Message-ID: <4C08D498.5090503@gmail.com> (raw)

The netlink_kernel_create failed will arouse memory leak,
this patch is to add the 'kfree(ue_sk)' here.

Signed-off-by: Wan ZongShun <mcuos.com@gmail.com>

---
 lib/kobject_uevent.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 59c1551..08e15f7 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -378,6 +378,7 @@ static int uevent_net_init(struct net *net)
 	if (!ue_sk->sk) {
 		printk(KERN_ERR
 		       "kobject_uevent: unable to create netlink socket!\n");
+		kfree(ue_sk);
 		return -ENODEV;
 	}
 	mutex_lock(&uevent_sock_mutex);
-- 
1.6.3.3

             reply	other threads:[~2010-06-04 10:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 10:25 Wan ZongShun [this message]
2010-06-04 15:27 ` [PATCH] lib: fix a memory leak risk Greg KH

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=4C08D498.5090503@gmail.com \
    --to=mcuos.com@gmail.com \
    --cc=gregkh@suse.de \
    --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