diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-08-01 20:12:35 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-08-01 20:12:35 +0000 |
commit | 85bda657b2578f68cd3945f1f967fae02a070d6a (patch) | |
tree | c613ecdb55d7eba3eedb1be8fcfb388cc8e5a9dc /sys | |
parent | 388de730ac96bb3b71c018fd573cbbd15c7ffd7c (diff) |
Fix free() of uninitialized variable introduced in previous commit.
Eliminate the goto that I tripped on.
problem noted by Mark Latimer (mark.latimer (at) gmail.com)
ok miod@ millert@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_ktrace.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 2e839f66e6a..aedc96f77fc 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.74 2015/07/19 04:45:25 guenther Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.75 2015/08/01 20:12:34 guenther Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -361,21 +361,17 @@ ktruser(struct proc *p, const char *id, const void *addr, size_t len) ktrinitheader(&kth, p, KTR_USER); memset(ktp.ktr_id, 0, KTR_USER_MAXIDLEN); error = copyinstr(id, ktp.ktr_id, KTR_USER_MAXIDLEN, NULL); - if (error) - goto out; - - if (len > sizeof(stkbuf)) - memp = malloc(len, M_TEMP, M_WAITOK); - else - memp = stkbuf; - error = copyin(addr, memp, len); - if (error) - goto out; - - ktrwrite2(p, &kth, &ktp, sizeof(ktp), memp, len); -out: - if (memp != stkbuf) - free(memp, M_TEMP, len); + if (error == 0) { + if (len > sizeof(stkbuf)) + memp = malloc(len, M_TEMP, M_WAITOK); + else + memp = stkbuf; + error = copyin(addr, memp, len); + if (error == 0) + ktrwrite2(p, &kth, &ktp, sizeof(ktp), memp, len); + if (memp != stkbuf) + free(memp, M_TEMP, len); + } atomic_clearbits_int(&p->p_flag, P_INKTR); return (error); } |