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:
parent
461710b119
commit
e515682daf
|
@ -43,10 +43,10 @@
|
||||||
static int console_change_speed(struct console_device *cdev, int baudrate)
|
static int console_change_speed(struct console_device *cdev, int baudrate)
|
||||||
{
|
{
|
||||||
int current_baudrate;
|
int current_baudrate;
|
||||||
|
const char *bstr;
|
||||||
|
|
||||||
current_baudrate =
|
bstr = dev_get_param(&cdev->class_dev, "baudrate");
|
||||||
(int)simple_strtoul(dev_get_param(&cdev->class_dev,
|
current_baudrate = bstr ? (int)simple_strtoul(bstr, NULL, 10) : 0;
|
||||||
"baudrate"), NULL, 10);
|
|
||||||
if (baudrate && baudrate != current_baudrate) {
|
if (baudrate && baudrate != current_baudrate) {
|
||||||
printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
|
printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
|
||||||
current_baudrate, baudrate);
|
current_baudrate, baudrate);
|
||||||
|
|
Loading…
Reference in New Issue