From 41cf74fe8ce5c6f8f10aa074e9405043a242a2b1 Mon Sep 17 00:00:00 2001 From: "Simon J. Gerraty" Date: Tue, 20 May 2025 09:10:50 -0700 Subject: [PATCH] loader - guard against empty rootdev At least one instance of u-boot pretending to be EFI is passing empty rootdev to loader which does not end well. A simple precaution is harmless. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D50334 --- stand/common/metadata.c | 2 +- stand/efi/loader/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/common/metadata.c b/stand/common/metadata.c index 22df6f175791..715354aedd04 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -111,7 +111,7 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64) * tested/set by MI code before launching the kernel. */ rootdevname = getenv("rootdev"); - if (rootdevname == NULL) + if (rootdevname == NULL || *rootdevname == '\0') rootdevname = getenv("currdev"); /* Try reading the /etc/fstab file to select the root device */ getrootmount(rootdevname); diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 2384fd08b964..c9a842afb06d 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -513,7 +513,7 @@ find_currdev(bool do_bootmgr, bool is_last, * it's wrong. */ rootdev = getenv("rootdev"); - if (rootdev != NULL) { + if (rootdev != NULL && *rootdev != '\0') { printf(" Setting currdev to configured rootdev %s\n", rootdev); set_currdev(rootdev);