mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: loady: fix bug with netconsole
@ 2015-01-01 20:04 Robert Jarzmik
  2015-01-01 20:04 ` [PATCH] net: smc1111: fix memory congestions Robert Jarzmik
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Robert Jarzmik @ 2015-01-01 20:04 UTC (permalink / raw)
  To: barebox

Netconsole doesn't have a baudrate. Loady supposes a console has one,
and tries to compute the console's baudrate variable value, regardless
of its existence.

This triggers a NULL pointer dereference on netconsole. If attempting
loady on a netconsole is a bit useless, barebox should not panic. Fix
this by checking the variable exists before reading its value.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 commands/loadxy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/commands/loadxy.c b/commands/loadxy.c
index df14043..1e65cb6 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -43,10 +43,10 @@
 static int console_change_speed(struct console_device *cdev, int baudrate)
 {
 	int current_baudrate;
+	const char *bstr;
 
-	current_baudrate =
-		(int)simple_strtoul(dev_get_param(&cdev->class_dev,
-						  "baudrate"), NULL, 10);
+	bstr = dev_get_param(&cdev->class_dev, "baudrate");
+	current_baudrate = bstr ? (int)simple_strtoul(bstr, NULL, 10) : 0;
 	if (baudrate && baudrate != current_baudrate) {
 		printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
 		       current_baudrate, baudrate);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-01-06 13:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01 20:04 [PATCH] commands: loady: fix bug with netconsole Robert Jarzmik
2015-01-01 20:04 ` [PATCH] net: smc1111: fix memory congestions Robert Jarzmik
2015-01-05 12:11   ` Sascha Hauer
2015-01-05 16:16     ` robert.jarzmik
2015-01-06 13:58       ` Sascha Hauer
2015-01-01 20:04 ` [PATCH] net: smc1111: move print_packet function Robert Jarzmik
2015-01-05 12:12   ` Sascha Hauer
2015-01-05 12:12 ` [PATCH] commands: loady: fix bug with netconsole Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox