From: Jesper Juhl <jesper.juhl@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org, Patrick Mochel <mochel@osdl.org>,
Patrick Mochel <mochel@infinity.powertie.org>
Subject: [PATCH] Don't leak 'old_class_name' in drivers/base/core.c::device_rename()
Date: Thu, 28 Sep 2006 23:56:01 +0200 [thread overview]
Message-ID: <200609282356.01962.jesper.juhl@gmail.com> (raw)
If kmalloc() fails to allocate space for 'old_symlink_name' in
drivers/base/core.c::device_rename(), then we'll leak 'old_class_name'.
Spotted by the Coverity checker.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
drivers/base/core.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--- linux-2.6.18-git10-orig/drivers/base/core.c 2006-09-28 22:39:53.000000000 +0200
+++ linux-2.6.18-git10/drivers/base/core.c 2006-09-28 23:48:51.000000000 +0200
@@ -805,8 +805,10 @@ int device_rename(struct device *dev, ch
if (dev->class) {
old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
- if (!old_symlink_name)
- return -ENOMEM;
+ if (!old_symlink_name) {
+ error = -ENOMEM;
+ goto out_free_old_class;
+ }
strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE);
}
@@ -830,9 +832,10 @@ int device_rename(struct device *dev, ch
}
put_device(dev);
- kfree(old_class_name);
kfree(new_class_name);
kfree(old_symlink_name);
+ out_free_old_class:
+ kfree(old_class_name);
return error;
}
next reply other threads:[~2006-09-28 21:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-28 21:56 Jesper Juhl [this message]
2006-09-29 8:13 ` Cornelia Huck
2006-09-29 8:48 ` Andrew Morton
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=200609282356.01962.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@infinity.powertie.org \
--cc=mochel@osdl.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
Powered by JetHome