summaryrefslogtreecommitdiffstats
path: root/lib/libkvm/kvm.c
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-03-27 18:22:33 +0000
committerngie <ngie@FreeBSD.org>2017-03-27 18:22:33 +0000
commitdbb0c0010ec41428ba46740d8b2a5669ea05f1b3 (patch)
tree83dc67533c6fd140c3e7d19ac268421f6c0c0759 /lib/libkvm/kvm.c
parent5ae64e785110cdeba9bef6771bbccaf30b04126b (diff)
downloadFreeBSD-src-dbb0c0010ec41428ba46740d8b2a5669ea05f1b3.zip
FreeBSD-src-dbb0c0010ec41428ba46740d8b2a5669ea05f1b3.tar.gz
MFC r315595,r315601,r315603,r315647:
r315595: Remove a commented out line before kvm_getprocs(3) The commented out return value for kvm_getprocs(3) was misleading -- the uncommented line is correct. No content change r315601: kvm_open2(3): remove '*' when describing addr argument for `resolver` As noted by vangyzen, with a similar issue in D10022, the pointer portion of the .Fa macro call is unnecessary, so remove the '*'. r315603: kvm_close(3): return `error` instead of blindly returning `0` `error` is the accumulated error from previous close(2) calls. This bug has been present since the libcall's import from 4.4BSD Lite (r1573). Noticed by: vangyzen (D10022) Relnotes: yes r315647: Handle kd == NULL gracefully with kvm_close(3) Don't segfault in kvm_close(3) if provided a NULL pointer. Instead, return -1 and set errno to EINVAL. Document this new behavior explicitly.
Diffstat (limited to 'lib/libkvm/kvm.c')
-rw-r--r--lib/libkvm/kvm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index 0de0dd6..2f95a20 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -534,6 +534,10 @@ kvm_close(kvm_t *kd)
{
int error = 0;
+ if (kd == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
if (kd->vmst != NULL)
kd->arch->ka_freevtop(kd);
if (kd->pmfd >= 0)
@@ -552,7 +556,7 @@ kvm_close(kvm_t *kd)
free((void *)kd->argv);
free((void *)kd);
- return (0);
+ return (error);
}
/*
OpenPOWER on IntegriCloud