Date: Tue, 11 May 2021 23:15:17 GMT From: Robert Wing <rew@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: a7f81b488df2 - main - libvmm: explicitly save and restore errno in vm_open() Message-ID: <202105112315.14BNFHMt008389@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=a7f81b488df2d4a5dcd785b4112e04ffb6ca0442 commit a7f81b488df2d4a5dcd785b4112e04ffb6ca0442 Author: Robert Wing <rew@FreeBSD.org> AuthorDate: 2021-03-11 19:27:43 +0000 Commit: Robert Wing <rew@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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105112315.14BNFHMt008389>