of: base: fix segfault in of_get_machine_compatible()
PATCH 1/1 of: base: fix segfault in of_get_machine_compatible()
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, ',');
--- drivers/of/base.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/base.c +2 -0
@@ -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;
Signature · 7 lines
2.15.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 11 lines · Aleksander Morgado
This is running the barebox sandbox:
Thread 1 "barebox" received signal SIGSEGV, Segmentation fault.
0x0000555555579e2bin_strchr(s=s@entry=0x0, c=c@entry=44) atlib/string.c:251
251for(; *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 ()
Quoted 8 lines
(gdb) fr 1
#10x000055555556fd91inof_get_machine_compatible() atdrivers/of/base.c:2380
2380 p =strchr(name, ',');Signed-off-by Aleksander Morgado <[email protected]>--- drivers/of/base.c | 2 ++ 1 file changed, 2 insertions(+)
Applied, thanks
Sascha
Quoted 18 lines
drivers/of/base.c +2
-0@@ -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;Signature · 1 line
2.15.1
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox