mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Ott <sebott@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: kay.sievers@vrfy.org, gregkh@suse.de
Subject: [PATCH] kobject_set_name: free old_name in case of ENOMEM
Date: Wed, 9 Sep 2009 18:53:21 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.0909091838080.3303@localhost.localdomain> (raw)


If the memory allocation for the kobject's name fails we should free
the old_name since it is no longer accessible via kobj->name.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
 lib/kobject.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: git.linux-2.6/lib/kobject.c
===================================================================
--- git.linux-2.6.orig/lib/kobject.c	2009-06-17 10:35:55.000000000 +0200
+++ git.linux-2.6/lib/kobject.c	2009-09-09 18:21:39.000000000 +0200
@@ -222,8 +222,10 @@ int kobject_set_name_vargs(struct kobjec
 		return 0;
 
 	kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
-	if (!kobj->name)
+	if (!kobj->name) {
+		kfree(old_name);
 		return -ENOMEM;
+	}
 
 	/* ewww... some of these buggers have '/' in the name ... */
 	while ((s = strchr(kobj->name, '/')))

             reply	other threads:[~2009-09-09 16:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-09 16:53 Sebastian Ott [this message]
2009-09-09 17:03 ` 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=alpine.LFD.2.00.0909091838080.3303@localhost.localdomain \
    --to=sebott@linux.vnet.ibm.com \
    --cc=gregkh@suse.de \
    --cc=kay.sievers@vrfy.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®