Avoid division by zero in serial.
This commit is contained in:
parent
4816dcac19
commit
e95685dab1
3 changed files with 17 additions and 1 deletions
|
@ -220,8 +220,12 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
|
||||
config = port->config;
|
||||
|
||||
if (state[OPTION_SPEED].set)
|
||||
if (state[OPTION_SPEED].set) {
|
||||
config.speed = grub_strtoul (state[OPTION_SPEED].arg, 0, 0);
|
||||
if (config.speed == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("unsupported serial port parity"));
|
||||
}
|
||||
|
||||
if (state[OPTION_WORD].set)
|
||||
config.word_len = grub_strtoul (state[OPTION_WORD].arg, 0, 0);
|
||||
|
@ -275,6 +279,9 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
config.base_clock *= 1000;
|
||||
}
|
||||
|
||||
if (config.speed == 0)
|
||||
config.speed = 9600;
|
||||
|
||||
/* Initialize with new settings. */
|
||||
err = port->driver->configure (port, &config);
|
||||
if (err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue