mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andy Botting <andy@andybotting.com>
Subject: Re: Crash with kfree(null) on MacBook? kobject_set_name_vargs
Date: Mon, 11 Apr 2011 10:48:08 -0700	[thread overview]
Message-ID: <BANLkTimfpRwsBUWcoNA1uDb8QfQP6USKEA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=R_D9ujCFeKv_o_U83GAR35X3TOQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 853 bytes --]

2011/4/11 Linus Torvalds <torvalds@linux-foundation.org>:
>
> prints out NULL is because the string printout code does this:
>
>        if ((unsigned long)s < PAGE_SIZE)
>                s = "(null)";
>
> which admittedly is not very helpful in this case (but it's usually
> nicer than just oopsing).

You could try this (UNTESTED!) patch to avoid this particular issue.
It will (well, unless I screwed up) print non-NULL pointers as the hex
value they have. So you should see "0x202" instead of "(null)" in that
case.

Of course, it sounds like _you_ don't actually see the bug at all,
because for you it probably really _is_ NULL. The people who see the
bug have some random non-null value, probably because of the field
just not being initialized properly, and containing some crud.

                                       Linus

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 577 bytes --]

 lib/vsprintf.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index bc0ac6b333dc..dabc310684bf 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -400,8 +400,14 @@ char *string(char *buf, char *end, const char *s, struct printf_spec spec)
 {
 	int len, i;
 
-	if ((unsigned long)s < PAGE_SIZE)
+	if ((unsigned long)s < PAGE_SIZE) {
+		if (s) {
+			spec.base = 16;
+			spec.flags |= SPECIAL;
+			return number(buf, end, (unsigned long)s, spec);
+		}
 		s = "(null)";
+	}
 
 	len = strnlen(s, spec.precision);
 

  reply	other threads:[~2011-04-11 17:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10 17:14 Rafał Miłecki
2011-04-10 17:15 ` Rafał Miłecki
2011-04-10 21:28 ` Bob Copeland
2011-04-11 17:28   ` Rafał Miłecki
2011-04-11 17:41 ` Linus Torvalds
2011-04-11 17:48   ` Linus Torvalds [this message]
2011-04-11 19:38   ` Rafał Miłecki
2011-04-27 14:03     ` Steven Rostedt

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=BANLkTimfpRwsBUWcoNA1uDb8QfQP6USKEA@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=andy@andybotting.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zajec5@gmail.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

all inboxes | Powered by JetHome®