9
0
Fork 0

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>
This commit is contained in:
Robert Jarzmik 2015-01-01 21:04:21 +01:00 committed by Sascha Hauer
parent 461710b119
commit e515682daf
1 changed files with 3 additions and 3 deletions

View File

@ -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);