git: 3a1bfbb50409 - stable/12 - efinet_dev_init() is missing NULL pointer check

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

URL: https://cgit.FreeBSD.org/src/commit/?id=3a1bfbb504099b533a6574f5e72fe739346ab191

commit 3a1bfbb504099b533a6574f5e72fe739346ab191
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2020-02-20 08:48:34 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-10-08 01:15:58 +0000

    efinet_dev_init() is missing NULL pointer check
    
    Add missing check of malloc() result.
    
    (cherry picked from commit 860545e20b8f09881973b828863f55141fb2250e)
---
 stand/efi/libefi/efinet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/stand/efi/libefi/efinet.c b/stand/efi/libefi/efinet.c
index 418790524e4a..c52b11d32ec8 100644
--- a/stand/efi/libefi/efinet.c
+++ b/stand/efi/libefi/efinet.c
@@ -371,6 +371,8 @@ efinet_dev_init()
 	status = BS->LocateHandle(ByProtocol, &sn_guid, NULL, &sz, NULL);
 	if (status == EFI_BUFFER_TOO_SMALL) {
 		handles = (EFI_HANDLE *)malloc(sz);
+		if (handles == NULL)
+			return (ENOMEM);
 		status = BS->LocateHandle(ByProtocol, &sn_guid, NULL, &sz,
 		    handles);
 		if (EFI_ERROR(status))