- Change utrace ktrace events to malloc the work buffer before getting a

request structure.
- Re-optimize the case of utrace being disabled by doing an explicit
  KTRPOINT check instead of relying on the one in ktr_getrequest() so that
  we don't waste time on a malloc in the non-tracing case.
- Change utrace() to return an error if the copyin() fails.  Before it
  would just ignore the request but still return success.  This last is
  a change in behavior and can be backed out if necessary.
This commit is contained in:
John Baldwin 2002-09-11 21:00:56 +00:00
parent 1d3ab18279
commit c9e7d28e26

View File

@ -613,21 +613,22 @@ utrace(td, uap)
#ifdef KTRACE
struct ktr_request *req;
void *cp;
int error;
if (!KTRPOINT(td, KTR_USER))
return (0);
if (uap->len > KTR_USER_MAXLEN)
return (EINVAL);
cp = malloc(uap->len, M_KTRACE, M_WAITOK);
error = copyin(uap->addr, cp, uap->len);
if (error)
return (error);
req = ktr_getrequest(KTR_USER);
if (req == NULL)
return (0);
cp = malloc(uap->len, M_KTRACE, M_WAITOK);
if (!copyin(uap->addr, cp, uap->len)) {
req->ktr_header.ktr_buffer = cp;
req->ktr_header.ktr_len = uap->len;
ktr_submitrequest(req);
} else {
ktr_freerequest(req);
td->td_inktrace = 0;
}
req->ktr_header.ktr_buffer = cp;
req->ktr_header.ktr_len = uap->len;
ktr_submitrequest(req);
return (0);
#else
return (ENOSYS);