From nobody Tue Apr 16 20:13:40 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VJwGX6xxXz5H0tM; Tue, 16 Apr 2024 20:13:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VJwGX2tMhz4vf4; Tue, 16 Apr 2024 20:13:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FFPYW7HdB5xmHla47rgfn4YJKzbgptajagyIozOwbc8=; b=MKXj3crf8GmLQOLQWFIJRE60mrUZfqPEHmFTHFMkWeA94YX4IV9VoNHh5UPvZZ53/aXzFN czuYqAGdE2tFaAdMiv9rRXg7nUdqveEIxl3tjcr8Eaq8whXhUSLg6NnrMNRG1ZSOU/EJW9 8gQCQ6xDJFelpsTwIbo9qAlLEwW3BGGBQN3C798zE+Z51Vv3SMVyhVImoUMWvVIn68fSxi AGtUTzfmkYJ8jIJmZwMoiNyR6WauZY8wtY7QUYLH88V+osnfKRF4CC8Cede1tuE268Qv0D 4DqdrMcbvBKePO9hqVA2gQqdTGCE0bX6h4dTBcSNFHRkWbuVnfiyniwekU1ZcA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298420; a=rsa-sha256; cv=none; b=Ggh4Ygn6FNkon4s2WLGj+FaIxrijcgqNDlqPjLPbNwZL9gCJ/EWVLPpQzuFYUfYr8Tg205 tC4HQfHn2i8SDao9q6Y4b0AM76UXN+9y5PSDvuPD2KNiPvEzxeOUzZOE2zx0x8OR7v5u9D OBMAco8fkWf1BuXAjN+vKIYKlSH1L9LZJsstJJ/U9CYiqwN/BqJvNbSFbKiwFppkWTB/Cf JFwU4oQIyfjf8L5FjmXgyO7pWojPfpI8QEXqqpT4xhC4D+tnUr6dB0NTdCs2aiSmY+qYlc toi4/fy9qzmQb0IHa25kKHo4xSyZZRf02F9AXbo8yWx/LJERGvtgA3CTsRFR3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FFPYW7HdB5xmHla47rgfn4YJKzbgptajagyIozOwbc8=; b=p+9iMLCDtPaj3KK7IuajZaVl+oecrtn37orioOCnAfin48U+QBiAIt1P7pQxYsv7t10YBD Wxwxl7+bhPvF3LHgzhsPPRnHpO6kPTnWlpAeVVrM5J17H1nZY/9v7Ax/5w9TMfAZmK9hV1 mOqNlMYPvDbN8GabyH3M50+MJfLpXx5+v3kfVzMg0VKOji7yo49O58i/MiA9uRrARPz+0G uneFYMowRqnGDrq+9JJqh+rF+diOtxAiUh7p9qlrjv3dWKdA6TxbUa4N1i+qvWt0Tq93VG NkOjmYRQplldBMlHKz9yarw5KakWLjWUUUlvbqddmA5kTstBk5f0DXuwjXharQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VJwGX2BCRzxdm; Tue, 16 Apr 2024 20:13:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GKDer4040155; Tue, 16 Apr 2024 20:13:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKDefL040152; Tue, 16 Apr 2024 20:13:40 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:13:40 GMT Message-Id: <202404162013.43GKDefL040152@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: e40703a705e5 - stable/14 - stand/efi: Changes to efichar to allow it to be used in the kernel List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e40703a705e598ab0faa8f43c0f75607a269c0db Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e40703a705e598ab0faa8f43c0f75607a269c0db commit e40703a705e598ab0faa8f43c0f75607a269c0db Author: Stephen J. Kiernan AuthorDate: 2024-03-27 22:37:48 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:30 +0000 stand/efi: Changes to efichar to allow it to be used in the kernel Replace malloc/free with EFICHAR_MALLOC and EFICHAR_FREEE macros. Obtained from: Juniper Networks, Inc. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44541 (cherry picked from commit fe429e6794d322636e7c1e520d50ec0cb711dd14) --- stand/efi/include/efichar.h | 8 ++++++++ stand/efi/libefi/efichar.c | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/stand/efi/include/efichar.h b/stand/efi/include/efichar.h index 4460f5efdcef..0a40906aeedf 100644 --- a/stand/efi/include/efichar.h +++ b/stand/efi/include/efichar.h @@ -37,4 +37,12 @@ int ucs2_to_utf8(const efi_char *, char **); int utf8_to_ucs2(const char *, efi_char **, size_t *); int ucs2len(const efi_char *); +#ifdef _KERNEL +#define EFICHAR_MALLOC(sz) malloc((sz), M_TEMP, M_WAITOK | M_ZERO) +#define EFICHAR_FREE(sz) free((sz), M_TEMP) +#else +#define EFICHAR_MALLOC(sz) malloc(sz) +#define EFICHAR_FREE(sz) free(sz) +#endif + #endif /* _BOOT_EFI_EFICHAR_H_ */ diff --git a/stand/efi/libefi/efichar.c b/stand/efi/libefi/efichar.c index 86642d325754..659212799b6a 100644 --- a/stand/efi/libefi/efichar.c +++ b/stand/efi/libefi/efichar.c @@ -25,14 +25,21 @@ */ #include +#ifndef _KERNEL #include +#endif #ifdef _STANDALONE #include #else +#ifdef _KERNEL +#include +#include +#else #include #include #include #include +#endif #include #include #endif @@ -87,7 +94,7 @@ ucs2_to_utf8(const efi_char *nm, char **name) if (*name != NULL) cp = *name; else - cp = *name = malloc(sz); + cp = *name = EFICHAR_MALLOC(sz); if (*name == NULL) return (ENOMEM); @@ -114,7 +121,7 @@ ucs2_to_utf8(const efi_char *nm, char **name) if (len >= sz) { /* Absent bugs, we'll never return EOVERFLOW */ if (freeit) { - free(*name); + EFICHAR_FREE(*name); *name = NULL; } return (EOVERFLOW); @@ -135,7 +142,7 @@ utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) sz = strlen(name) * 2 + 2; if (*nmp == NULL) - *nmp = malloc(sz); + *nmp = EFICHAR_MALLOC(sz); if (*nmp == NULL) return (ENOMEM); nm = *nmp; @@ -183,7 +190,7 @@ utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) } if (sz < 2) { if (freeit) { - free(nm); + EFICHAR_FREE(nm); *nmp = NULL; } return (EDOOFUS); @@ -194,7 +201,7 @@ utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) return (0); ilseq: if (freeit) { - free(nm); + EFICHAR_FREE(nm); *nmp = NULL; } return (EILSEQ);