Fix the efi serial console in the Arm models.
On some UEFI implementations the ConsOut EFI variable is not a device path end type so we never move to the next node. Fix this by always incrementing the device path node pointer, with a sanity check that the node length is large enough so no two nodes overlap. While here return failure on malloc failure rather than a NULL pointer dereference. Reviewed by: tsoome, imp (previous version) Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D25202
This commit is contained in:
parent
23e0e27c5a
commit
5895f51114
@ -216,8 +216,9 @@ comc_get_con_serial_handle(const char *name)
|
|||||||
status = efi_global_getenv(name, buf, &sz);
|
status = efi_global_getenv(name, buf, &sz);
|
||||||
if (status == EFI_BUFFER_TOO_SMALL) {
|
if (status == EFI_BUFFER_TOO_SMALL) {
|
||||||
buf = malloc(sz);
|
buf = malloc(sz);
|
||||||
if (buf != NULL)
|
if (buf == NULL)
|
||||||
status = efi_global_getenv(name, buf, &sz);
|
return (NULL);
|
||||||
|
status = efi_global_getenv(name, buf, &sz);
|
||||||
}
|
}
|
||||||
if (status != EFI_SUCCESS) {
|
if (status != EFI_SUCCESS) {
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -232,17 +233,13 @@ comc_get_con_serial_handle(const char *name)
|
|||||||
free(buf);
|
free(buf);
|
||||||
return (handle);
|
return (handle);
|
||||||
}
|
}
|
||||||
if (IsDevicePathEndType(node) &&
|
|
||||||
DevicePathSubType(node) ==
|
/* Sanity check the node before moving to the next node. */
|
||||||
END_INSTANCE_DEVICE_PATH_SUBTYPE) {
|
if (DevicePathNodeLength(node) < sizeof(*node))
|
||||||
/*
|
|
||||||
* Start of next device path in list.
|
|
||||||
*/
|
|
||||||
node = NextDevicePathNode(node);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (IsDevicePathEnd(node))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Start of next device path in list. */
|
||||||
|
node = NextDevicePathNode(node);
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user