Date: Tue, 16 Jan 2024 14:40:41 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: e2e956828caf - main - bhyve: return ENOMEM instead of EFAULT and call free() after being used Message-ID: <202401161440.40GEefh4063885@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e2e956828caf2f1db308d54b264c277c0abc25df commit e2e956828caf2f1db308d54b264c277c0abc25df Author: rilysh <nightquick@proton.me> AuthorDate: 2024-01-08 06:06:55 +0000 Commit: Mark Johnston <markj@FreeBSD.org> 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 <nightquick@proton.me> 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401161440.40GEefh4063885>