From: Linda Xie <lxiep@us.ibm.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Linda Xie <lxiep@us.ibm.com>,
linux-kernel@vger.kernel.org, Greg KH <gregkh@us.ibm.com>,
scheel@us.ibm.com, wortman@us.ibm.com
Subject: Re: PATCH -- kobject_set_name() doesn't allocate enough space
Date: Tue, 16 Dec 2003 17:24:43 -0600 [thread overview]
Message-ID: <3FDF943B.8020906@us.ltcfwd.linux.ibm.com> (raw)
In-Reply-To: Pine.LNX.4.58.0312161241570.1599@home.osdl.org
Linus Torvalds wrote:
>
> The patch looks correct, but you should change the last test to be
> appropriate too, ie the
>
> /* Still? Give up. */
> if (need > limit) {
>
> test should, as far as I can tell, be
>
> if (need >= limit) {
>
> instead.
>
> Linus
Hi Linus,
Thank you for pointing that out. Here is the updated patch:
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c Tue Dec 16 17:10:16 2003
+++ b/lib/kobject.c Tue Dec 16 17:10:16 2003
@@ -344,16 +344,16 @@
/*
* Need more space? Allocate it and try again
*/
- name = kmalloc(need,GFP_KERNEL);
+ limit = need + 1;
+ name = kmalloc(limit,GFP_KERNEL);
if (!name) {
error = -ENOMEM;
goto Done;
}
- limit = need;
need = vsnprintf(name,limit,fmt,args);
/* Still? Give up. */
- if (need > limit) {
+ if (need >= limit) {
kfree(name);
error = -EFAULT;
goto Done;
prev parent reply other threads:[~2003-12-16 23:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-16 20:15 PATCH -- kobject_set_name() doesn't allocate enough space Linda Xie
2003-12-16 20:44 ` Linus Torvalds
2003-12-16 23:24 ` Linda Xie [this message]
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=3FDF943B.8020906@us.ltcfwd.linux.ibm.com \
--to=lxiep@us.ibm.com \
--cc=gregkh@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=scheel@us.ibm.com \
--cc=torvalds@osdl.org \
--cc=wortman@us.ibm.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