diff options
author | Robert Jarzmik <robert.jarzmik@free.fr> | 2015-01-01 21:04:21 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-01-06 14:01:23 +0100 |
commit | 9fc366d5fb373ef2faf66152bfb8c47b441e243f (patch) | |
tree | f59e5aa08f551bcdece216f5b0c162e48388b513 | |
parent | 98c31edfa5605fbeb7f91e297bef058caedfe8a7 (diff) | |
download | barebox-9fc366d5fb373ef2faf66152bfb8c47b441e243f.tar.gz |
commands: loady: fix bug with netconsole
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | commands/loadxy.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/commands/loadxy.c b/commands/loadxy.c index df14043d69..1e65cb6221 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); |