devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] of: Fix crash if an earlycon driver is not found
@ 2014-11-09  8:55 Kevin Cernekee
  2014-11-09  8:55 ` [PATCH 2/2] tty: serial: bcm63xx: Allow device nodes to be renamed to /dev/ttyBCM* Kevin Cernekee
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Kevin Cernekee @ 2014-11-09  8:55 UTC (permalink / raw)
  To: gregkh, jslaby, robh
  Cc: grant.likely, f.fainelli, mbizon, jogo, linux-mips, linux-serial,
	devicetree, stable

__earlycon_of_table_sentinel.compatible is a char[128], not a pointer, so
it will never be NULL.  Checking it against NULL causes the match loop to
run past the end of the array, and eventually match a bogus entry, under
the following conditions:

 - Kernel command line specifies "earlycon" with no parameters
 - DT has a stdout-path pointing to a UART node
 - The UART driver doesn't use OF_EARLYCON_DECLARE (or maybe the console
   driver is compiled out)

Fix this by checking to see if match->compatible is a non-empty string.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Cc: <stable@vger.kernel.org> # 3.16+
---
 drivers/of/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1ffca8..30e97bc 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -773,7 +773,7 @@ int __init early_init_dt_scan_chosen_serial(void)
 	if (offset < 0)
 		return -ENODEV;
 
-	while (match->compatible) {
+	while (match->compatible[0]) {
 		unsigned long addr;
 		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
 			match++;
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-11-12 17:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09  8:55 [PATCH 1/2] of: Fix crash if an earlycon driver is not found Kevin Cernekee
2014-11-09  8:55 ` [PATCH 2/2] tty: serial: bcm63xx: Allow device nodes to be renamed to /dev/ttyBCM* Kevin Cernekee
2014-11-10 14:25   ` Rob Herring
2014-11-10 15:05     ` Kevin Cernekee
2014-11-10 18:30       ` Greg Kroah-Hartman
2014-11-10 19:10         ` Kevin Cernekee
2014-11-10 19:22       ` Rob Herring
2014-11-10 19:50         ` Kevin Cernekee
2014-11-11 17:35           ` Rob Herring
2014-11-11 19:50             ` Kevin Cernekee
2014-11-10 14:14 ` [PATCH 1/2] of: Fix crash if an earlycon driver is not found Rob Herring
2014-11-10 19:01   ` Sergei Shtylyov
2014-11-12 17:12   ` Grant Likely
2014-11-12 17:11 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).