git: a7f81b488df2 - main - libvmm: explicitly save and restore errno in vm_open()
Robert Wing
rew at FreeBSD.org
Tue May 11 23:15:17 UTC 2021
The branch main has been updated by rew:
URL: https://cgit.FreeBSD.org/src/commit/?id=a7f81b488df2d4a5dcd785b4112e04ffb6ca0442
commit a7f81b488df2d4a5dcd785b4112e04ffb6ca0442
Author: Robert Wing <rew at FreeBSD.org>
AuthorDate: 2021-03-11 19:27:43 +0000
Commit: Robert Wing <rew at FreeBSD.org>
CommitDate: 2021-05-11 23:11:52 +0000
libvmm: explicitly save and restore errno in vm_open()
In commit 6bb140e3ca895a14, vm_destroy() was replaced with free() to
preserve errno. However, it's possible that free() may change the errno
as well. Keep the free() call, but explicitly save and restore errno.
Noted by: jhb
Fixes: 6bb140e3ca895a14
---
lib/libvmmapi/vmmapi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 7faa2fc545ea..5810274c9a73 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -118,6 +118,7 @@ struct vmctx *
vm_open(const char *name)
{
struct vmctx *vm;
+ int saved_errno;
vm = malloc(sizeof(struct vmctx) + strlen(name) + 1);
assert(vm != NULL);
@@ -133,7 +134,9 @@ vm_open(const char *name)
return (vm);
err:
+ saved_errno = errno;
free(vm);
+ errno = saved_errno;
return (NULL);
}
More information about the dev-commits-src-main
mailing list