mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH] of: base: fix segfault in of_get_machine_compatible()
Date: Sun, 28 Jan 2018 14:08:28 +0100	[thread overview]
Message-ID: <20180128130828.10357-1-aleksander@aleksander.es> (raw)

This is running the barebox sandbox:

  Thread 1 "barebox" received signal SIGSEGV, Segmentation fault.
  0x0000555555579e2b in _strchr (s=s@entry=0x0, c=c@entry=44) at lib/string.c:251
  251		for(; *s != (char) c; ++s)
  (gdb) bt
  #0  0x0000555555579e2b in _strchr (s=s@entry=0x0, c=c@entry=44) at lib/string.c:251
  #1  0x000055555556fd91 in of_get_machine_compatible () at drivers/of/base.c:2380
  #2  0x000055555556fda8 in of_init_hostname () at drivers/of/base.c:2389
  #3  0x000055555555f9e6 in start_barebox () at common/startup.c:106
  #4  0x00005555555a291a in main ()
  (gdb) fr 1
  #1  0x000055555556fd91 in of_get_machine_compatible () at drivers/of/base.c:2380
  2380		p = strchr(name, ',');

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
---
 drivers/of/base.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 6a582177b..10b62890b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2376,6 +2376,8 @@ const char *of_get_machine_compatible(void)
 
 	prop = of_find_property(root_node, "compatible", NULL);
 	name = of_prop_next_string(prop, NULL);
+	if (!name)
+		return NULL;
 
 	p = strchr(name, ',');
 	return p ? p + 1 : name;
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2018-01-28 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-28 13:08 Aleksander Morgado [this message]
2018-01-30  6:56 ` Sascha Hauer

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=20180128130828.10357-1-aleksander@aleksander.es \
    --to=aleksander@aleksander.es \
    --cc=barebox@lists.infradead.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