git: 9e05a1578650 - stable/12 - efipart_inithandles() is missing NULL pointer check

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Fri, 08 Oct 2021 01:16:33 UTC
The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e05a157865009dc23e93753cfa09efd7bbbd738

commit 9e05a157865009dc23e93753cfa09efd7bbbd738
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2020-02-20 08:56:56 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-10-08 01:15:59 +0000

    efipart_inithandles() is missing NULL pointer check
    
    Add missing check of malloc() result.
    
    (cherry picked from commit 79cbcdcf3ececdb45f02c528d00e53e9600a4f48)
---
 stand/efi/libefi/efipart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c
index 0710a33fdf93..424df7d2e423 100644
--- a/stand/efi/libefi/efipart.c
+++ b/stand/efi/libefi/efipart.c
@@ -363,6 +363,8 @@ efipart_inithandles(void)
 	status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin);
 	if (status == EFI_BUFFER_TOO_SMALL) {
 		hin = malloc(sz);
+		if (hin == NULL)
+			return (ENOMEM);
 		status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz,
 		    hin);
 		if (EFI_ERROR(status))