stand: libefi: avoid a null pointer deref in eficom

We don't keep comc_port around anymore if the console's not present, but
some things might still try to set one of the environment variables we
hook.  In particular, one need not even set efi_com_port/efi_com_speed
in loader.conf; loader may do it itself and induce the crash if ConOut
depicts an available uart.

Probably reported by:	dch
OK for now:	imp
This commit is contained in:
Kyle Evans 2023-05-28 13:50:46 -05:00
parent 697727110b
commit 9ed4ec4ae3

View File

@ -497,7 +497,7 @@ comc_port_set(struct env_var *ev, int flags, const void *value)
EFI_HANDLE handle;
EFI_STATUS status;
if (value == NULL)
if (value == NULL || comc_port == NULL)
return (CMD_ERROR);
if (comc_parse_intval(value, &port) != CMD_OK)
@ -532,7 +532,7 @@ comc_speed_set(struct env_var *ev, int flags, const void *value)
{
unsigned speed;
if (value == NULL)
if (value == NULL || comc_port == NULL)
return (CMD_ERROR);
if (comc_parse_intval(value, &speed) != CMD_OK)