From nobody Tue Jan 16 14:40:41 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 4TDsBL39w2z57LtD; Tue, 16 Jan 2024 14:40:42 +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 4TDsBL0lysz4HD1; Tue, 16 Jan 2024 14:40:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705416042; 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=0eBxDjHD6TqOxApZB7rhTF6OFrZXCSdaRCQUpry8zKQ=; b=tUa5Q1Rf0Q9yPCjC/sa0Y2b4UtWoYFYQf6DM1zZmBVcXLHjUbdEemjRmbWTAwAG4op4f7H ObeOXXrQAtHL8X0kVUKIjQI1BN1BUO9aT0WzI37ZjMC6/p/ALn+Kj8zm2cCka/UYA+pT6K qrBanGFKts2J1TXpyjGwFBv6PRFGaUpsAsOPMV+nvaFkd1IpqU7FqnKa5bcnZzF/izwQtG pQk84lBHyInGFs2q2SduEGkmi0S6VJLZuT5OinQsaOJE/nXrDEovEom1WpUYJ/GN1bBf6F JaBGkTJHrI/159vWKSDxiELkhVt+C49aCVFcZjV9wkvPQbb0HgEWlWJD53+7Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705416042; 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=0eBxDjHD6TqOxApZB7rhTF6OFrZXCSdaRCQUpry8zKQ=; b=IqLklbDsY9Niq0wp0oUjSjtKU1sxPF+EwJbp0dsPZktXm62T4oZMBf5G2JBIUUyvUBjDkj EjHx1NIlbuJ/j9pOgkrZM6DqggQp+cuFuRvS+AcYbRMS3lcP9DBaoKB4ZxweqYhCGumxRp kGKZtHdbQqpnYqaE3DrccVSaoRnGwEsBSVlMlES4cubgUaCKUEqrwX3dO8OHFFmdfDbmvB kmeWo1ytyIvTowjlu0nvcqwVETPcOpQCPiR4FcVZPiIC+62dPy76xaOtQWyvLXg5eeeg4P FKM5NsrGPaL6C1VfT9u4u0N1cIOHKwAu6H6q+/WDKjxhawsRVqPZQAf9psKFng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705416042; a=rsa-sha256; cv=none; b=iwqUyC/3FhXw0fZVvGYot7JYXPm7SFtNu0V9P/xOt5QXh3fn8vd4+NpFMH0N2j6RenRYf0 c3lC4MJEBPBgrT+83lksgFtFjtMa/De4YBSsAKwt0gOLj4k4czaGHIqhD9ErHMFELC7M1o S5n9uGRjiJ7AJNCPmde8CW7lhtFDCJ7cktZcx8CskSOg1nuUz3D6Tk0OuU082QE/vjqteu UmN+IrEzW6VCTemoJTzYNhV61aWA98gfT/k8V5t8mj+wovrTQTaP51OsJTnFyE7SpAnrtd av/0f+WtBrbkjBqHx+PaCkKGTBT6Dgpnrrr6UnWifOqHJMEg9+MHw9CIFSOhFQ== 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 4TDsBK6yXLzkZP; Tue, 16 Jan 2024 14:40:41 +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 40GEefWW063888; Tue, 16 Jan 2024 14:40:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40GEefh4063885; Tue, 16 Jan 2024 14:40:41 GMT (envelope-from git) Date: Tue, 16 Jan 2024 14:40:41 GMT Message-Id: <202401161440.40GEefh4063885@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e2e956828caf - main - 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/main X-Git-Reftype: branch X-Git-Commit: e2e956828caf2f1db308d54b264c277c0abc25df Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e2e956828caf2f1db308d54b264c277c0abc25df commit e2e956828caf2f1db308d54b264c277c0abc25df Author: rilysh AuthorDate: 2024-01-08 06:06:55 +0000 Commit: Mark Johnston CommitDate: 2024-01-16 14:39:25 +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 --- 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 b3d3c13fc946..85864da57af2 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -326,7 +326,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); @@ -338,6 +338,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); }