* [PATCH] console: console_get_by_name: do not strcmp NULL
@ 2017-03-26 14:17 Alexander Kurz
2017-03-29 6:50 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kurz @ 2017-03-26 14:17 UTC (permalink / raw)
To: barebox; +Cc: Alexander Kurz
console_get_by_name iterates through the console_list using strcmp to mach
a given console by name. console_list may contain entries with devname = NULL,
inserted there e.g. by KEYBOARD_GPIO. In worst case loady -t usbserial
will crash barebox when strcmp hits 0 NULL devname:
> unable to handle NULL pointer dereference at address 0x00000000
Let console_get_by_name just ignore the anonymous consoles.
Signed-off-by: Alexander Kurz <akurz@blala.de>
---
common/console_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/console_common.c b/common/console_common.c
index 2e5869f..d051458 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -246,7 +246,7 @@ struct console_device *console_get_by_name(const char *name)
struct console_device *cdev;
for_each_console(cdev) {
- if (!strcmp(cdev->devname, name))
+ if (cdev->devname && !strcmp(cdev->devname, name))
return cdev;
}
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] console: console_get_by_name: do not strcmp NULL
2017-03-26 14:17 [PATCH] console: console_get_by_name: do not strcmp NULL Alexander Kurz
@ 2017-03-29 6:50 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2017-03-29 6:50 UTC (permalink / raw)
To: Alexander Kurz; +Cc: barebox
On Sun, Mar 26, 2017 at 04:17:12PM +0200, Alexander Kurz wrote:
> console_get_by_name iterates through the console_list using strcmp to mach
> a given console by name. console_list may contain entries with devname = NULL,
> inserted there e.g. by KEYBOARD_GPIO. In worst case loady -t usbserial
> will crash barebox when strcmp hits 0 NULL devname:
> > unable to handle NULL pointer dereference at address 0x00000000
>
> Let console_get_by_name just ignore the anonymous consoles.
>
> Signed-off-by: Alexander Kurz <akurz@blala.de>
> ---
Applied to master, thanks
Sascha
> common/console_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/console_common.c b/common/console_common.c
> index 2e5869f..d051458 100644
> --- a/common/console_common.c
> +++ b/common/console_common.c
> @@ -246,7 +246,7 @@ struct console_device *console_get_by_name(const char *name)
> struct console_device *cdev;
>
> for_each_console(cdev) {
> - if (!strcmp(cdev->devname, name))
> + if (cdev->devname && !strcmp(cdev->devname, name))
> return cdev;
> }
>
> --
> 2.1.4
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-29 6:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-26 14:17 [PATCH] console: console_get_by_name: do not strcmp NULL Alexander Kurz
2017-03-29 6:50 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox