git: 46927f674466 - main - stand/efi/eficom: Free comc_port if we can't find the serial port

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 25 May 2023 04:34:06 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=46927f674466965db76f8e3138bcc630cdd6ed11

commit 46927f674466965db76f8e3138bcc630cdd6ed11
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-05-24 22:34:51 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-05-25 04:33:53 +0000

    stand/efi/eficom: Free comc_port if we can't find the serial port
    
    If we can't find the serial port, free comc_port and return early. The
    serial port just isn't there.
    
    Sponsored by:           Netflix
    Reviewed by:            kevans
    Differential Revision:  https://reviews.freebsd.org/D40223
---
 stand/efi/libefi/eficom.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/stand/efi/libefi/eficom.c b/stand/efi/libefi/eficom.c
index 6ff8512dedd7..4c104114d445 100644
--- a/stand/efi/libefi/eficom.c
+++ b/stand/efi/libefi/eficom.c
@@ -329,6 +329,16 @@ comc_probe(struct console *sc)
 		}
 	}
 
+	/*
+	 * If there's no sio, then the device isn't there, so just return since
+	 * the present flags aren't yet set.
+	 */
+	if (comc_port->sio == NULL) {
+		free(comc_port);
+		comc_port = NULL;
+		return;
+	}
+
 	if (env != NULL) 
 		unsetenv("efi_com_port");
 	snprintf(value, sizeof (value), "%u", comc_port->ioaddr);