aboutsummaryrefslogtreecommitdiff
path: root/sys/boot
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2017-11-12 17:15:54 +0000
committerEd Maste <emaste@FreeBSD.org>2017-11-12 17:15:54 +0000
commit1ec77552861ce2d66f6bcc679fcafc89dbba680f (patch)
tree49b60c7ab0cc0f8a55b7c8ae29ba9bc5c2a01351 /sys/boot
parent175748c9824ba72ffd68930377df45a22f93eaef (diff)
boot1: also check for NULL device
r325681 fixed a NULL pointer dereference on RPi3 caused by a lack of functionality in uboot's EFI implementation. That rev checked the boot1 load path for NULL but not the load device. In practice if the former works the latter will as well, but improve correctness by checking each separately. Submitted by: Keith White <kwhite@eecs.uottawa.ca> Reported by: jhb MFC after: 5 days MFC with: r325681 Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=325744
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/efi/boot1/boot1.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/boot/efi/boot1/boot1.c b/sys/boot/efi/boot1/boot1.c
index 71723fe74448..b7cb57f45530 100644
--- a/sys/boot/efi/boot1/boot1.c
+++ b/sys/boot/efi/boot1/boot1.c
@@ -464,14 +464,16 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
printf(" Load Path: %S\n", text);
efi_setenv_freebsd_wcs("Boot1Path", text);
efi_free_devpath_name(text);
+ }
- status = BS->HandleProtocol(img->DeviceHandle,
- &DevicePathGUID, (void **)&imgpath);
- if (status != EFI_SUCCESS) {
- DPRINTF("Failed to get image DevicePath (%lu)\n",
- EFI_ERROR_CODE(status));
- } else {
- text = efi_devpath_name(imgpath);
+ status = BS->HandleProtocol(img->DeviceHandle, &DevicePathGUID,
+ (void **)&imgpath);
+ if (status != EFI_SUCCESS) {
+ DPRINTF("Failed to get image DevicePath (%lu)\n",
+ EFI_ERROR_CODE(status));
+ } else {
+ text = efi_devpath_name(imgpath);
+ if (text != NULL) {
printf(" Load Device: %S\n", text);
efi_setenv_freebsd_wcs("Boot1Dev", text);
efi_free_devpath_name(text);