summaryrefslogtreecommitdiffstats
path: root/common/console_common.c
diff options
context:
space:
mode:
authorAlexander Kurz <akurz@blala.de>2017-03-26 16:17:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-29 08:50:16 +0200
commite6419c64cfcb6001e8ded6fa4ce05aebc9c52eac (patch)
tree99bcfa6137341b44ba593ea068da69352040c7b7 /common/console_common.c
parent444ee36545998cad54e6b1df7bec604b1fa9834c (diff)
downloadbarebox-e6419c64cfcb6001e8ded6fa4ce05aebc9c52eac.tar.gz
barebox-e6419c64cfcb6001e8ded6fa4ce05aebc9c52eac.tar.xz
console: console_get_by_name: do not strcmp NULL
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console_common.c')
-rw-r--r--common/console_common.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/console_common.c b/common/console_common.c
index 2e5869fab0..d051458de4 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;
}