git: f1186fab56e8 - stable/14 - bhyve: return ENOMEM instead of EFAULT and call free() after being used
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 25 Jan 2024 15:02:32 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f1186fab56e86b963a127bcdacbd1e8e1f03acf2 commit f1186fab56e86b963a127bcdacbd1e8e1f03acf2 Author: rilysh <nightquick@proton.me> AuthorDate: 2024-01-08 06:06:55 +0000 Commit: Mark Johnston <markj@FreeBSD.org> 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 <nightquick@proton.me> 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); }