From nobody Thu Jan 25 15:02:32 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 4TLPFN73fpz57QV9; Thu, 25 Jan 2024 15:02:32 +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 4TLPFN5VkMz4pWG; Thu, 25 Jan 2024 15:02:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706194952; 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=9vcueVoo2+b6uQWchw6zWRhca2o9hE19y0Amdy7st0k=; b=rhcLlgcOBIZmZe+v72vSJiJYjXusj3SnUvNk5RISwDXtOCyMGN38VMP/kfYeHUzmgFP3zg lzoyxby/P3+qox70w3HlneckkxLZ+abAGivj1k6mCPjUVCwXu6p0ZYKApgs7pXtv21ZBrC 06bGBY6H+ltb53xCVIqShKHqAG/FyC/57mZOgaXEh6Q8wJd7g+vF44hntMEIRnmwNMhpzB Rd/s/QvRq8jju173vrdY7wfR/EkzQ0A+TfsdVwdCJ6ib8SOaNfuaaZeblIsCwneB2KZWnL lfg19XRZ6BcRlhZNGoRbIWQxAJzyrjy3/Ze9dyVjg1F9IeSh3ScGNEoesABNUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706194952; 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=9vcueVoo2+b6uQWchw6zWRhca2o9hE19y0Amdy7st0k=; b=S87tUevQHt4/8XuadRiH9Q9wabeCNn32jZMwARNTCHJioOOGV4MT2NMuHJT7ZVQ/WN/4fP BD/hY2wZYD8G/Rdj0h9gOkM0zWCCaCd+METelZCZ2hEpK/qS1uqZSwkOd1iJo9sQtESUTF pQO06Y1IXhv7ttkzj+PBczZK3fp4zb9AB7qtSW80fPX+h3pSZo7g/t/pZz1kGtwOpVWdSO G6fEpxus/X7WzKPB8xBU/b0ikH1+a39phoEzr4KlaKoYMxXeo2U+U2XNMertz0ilVDhw5T z8bXjR/Epl0mKoCmzE2l9TEaHDSMSXhWliQ/JQwtvxAaOGegdvyP6LVbqlxeIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706194952; a=rsa-sha256; cv=none; b=d13AuNw6UjXe/9i2dZCHLaqvIBJvj2rZnInA6HWiAyZuyT/nfInEqhOgd+Qupk0Hi6WbgR 4nU+bry6y9sDCz/0TConam7e7HIblA8sAyRvZXuCEEZK6X3CuZgpZYRWM/WBjmxipPKAYY fqG0C6VW7RS/YhkOzN4aMMEstJQ86yLrZj2UsONq/IKHgscxKoi2Y/KgxAueyEXK8n1rOt dYCEAEBoGOq75XTEYYwMuEpPcGMxAGE1t/NQSJruTnyNAciZ0hPAy/4ii6aZjDICdaT3tC kWGUJabgaKldjv7zuvlJy+9FG3LoiHkFubkf/A0bQjNYczkm3icbYku3rYEqBA== 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 4TLPFN4bTFz12MR; Thu, 25 Jan 2024 15:02:32 +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 40PF2Wg7057066; Thu, 25 Jan 2024 15:02:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40PF2WiU057063; Thu, 25 Jan 2024 15:02:32 GMT (envelope-from git) Date: Thu, 25 Jan 2024 15:02:32 GMT Message-Id: <202401251502.40PF2WiU057063@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: f1186fab56e8 - stable/14 - bhyve: return ENOMEM instead of EFAULT and call free() after being used 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f1186fab56e86b963a127bcdacbd1e8e1f03acf2 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f1186fab56e86b963a127bcdacbd1e8e1f03acf2 commit f1186fab56e86b963a127bcdacbd1e8e1f03acf2 Author: rilysh AuthorDate: 2024-01-08 06:06:55 +0000 Commit: Mark Johnston CommitDate: 2024-01-25 14:57:05 +0000 bhyve: return ENOMEM instead of EFAULT and call free() after being used 1. In basl_load() function, when allocation fails, it returns an EFAULT instead of ENOMEM. An EFAULT can mislead in some scenarios, whereas an ENOMEM for an allocation function makes much more sense. 2. Call free() on addr, as it's not being used anymore after the basl_table_append_bytes() function. Signed-off-by: rilysh MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1016 (cherry picked from commit e2e956828caf2f1db308d54b264c277c0abc25df) --- usr.sbin/bhyve/acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 050e1a0ab75f..db253aeb523d 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -327,7 +327,7 @@ basl_load(struct vmctx *ctx, int fd) addr = calloc(1, sb.st_size); if (addr == NULL) - return (EFAULT); + return (ENOMEM); if (read(fd, addr, sb.st_size) < 0) return (errno); @@ -339,6 +339,7 @@ basl_load(struct vmctx *ctx, int fd) BASL_EXEC(basl_table_create(&table, ctx, name, BASL_TABLE_ALIGNMENT)); BASL_EXEC(basl_table_append_bytes(table, addr, sb.st_size)); + free(addr); return (0); }