mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Kurz <akurz@blala.de>
To: barebox@lists.infradead.org
Cc: Alexander Kurz <akurz@blala.de>
Subject: [PATCH] console: console_get_by_name: do not strcmp NULL
Date: Sun, 26 Mar 2017 16:17:12 +0200	[thread overview]
Message-ID: <1490537832-14971-1-git-send-email-akurz@blala.de> (raw)

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

             reply	other threads:[~2017-03-26 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-26 14:17 Alexander Kurz [this message]
2017-03-29  6:50 ` 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=1490537832-14971-1-git-send-email-akurz@blala.de \
    --to=akurz@blala.de \
    --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