Preserve the errno value of an ioctl before calling free(3). Previously,
errno was very occasionally being clobbered, resulting in a bogus error from dt_consume() and thus an error from dtrace(1). MFC after: 2 weeks
This commit is contained in:
parent
55806cca37
commit
47890cb590
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=269524
@ -2944,7 +2944,7 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp)
|
||||
{
|
||||
dtrace_optval_t size;
|
||||
dtrace_bufdesc_t *buf = dt_zalloc(dtp, sizeof (*buf));
|
||||
int error;
|
||||
int error, rval;
|
||||
|
||||
if (buf == NULL)
|
||||
return (-1);
|
||||
@ -2963,7 +2963,6 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp)
|
||||
#else
|
||||
if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) {
|
||||
#endif
|
||||
dt_put_buf(dtp, buf);
|
||||
/*
|
||||
* If we failed with ENOENT, it may be because the
|
||||
* CPU was unconfigured -- this is okay. Any other
|
||||
@ -2971,10 +2970,12 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp)
|
||||
*/
|
||||
if (errno == ENOENT) {
|
||||
*bufp = NULL;
|
||||
return (0);
|
||||
}
|
||||
rval = 0;
|
||||
} else
|
||||
rval = dt_set_errno(dtp, errno);
|
||||
|
||||
return (dt_set_errno(dtp, errno));
|
||||
dt_put_buf(dtp, buf);
|
||||
return (rval);
|
||||
}
|
||||
|
||||
error = dt_unring_buf(dtp, buf);
|
||||
|
@ -39,7 +39,7 @@
|
||||
static int
|
||||
dt_strdata_add(dtrace_hdl_t *dtp, dtrace_recdesc_t *rec, void ***data, int *max)
|
||||
{
|
||||
int maxformat;
|
||||
int maxformat, rval;
|
||||
dtrace_fmtdesc_t fmt;
|
||||
void *result;
|
||||
|
||||
@ -63,8 +63,9 @@ dt_strdata_add(dtrace_hdl_t *dtp, dtrace_recdesc_t *rec, void ***data, int *max)
|
||||
return (dt_set_errno(dtp, EDT_NOMEM));
|
||||
|
||||
if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) {
|
||||
rval = dt_set_errno(dtp, errno);
|
||||
free(fmt.dtfd_string);
|
||||
return (dt_set_errno(dtp, errno));
|
||||
return (rval);
|
||||
}
|
||||
|
||||
while (rec->dtrd_format > (maxformat = *max)) {
|
||||
|
@ -184,7 +184,7 @@ dtrace_go(dtrace_hdl_t *dtp)
|
||||
{
|
||||
dtrace_enable_io_t args;
|
||||
void *dof;
|
||||
int err;
|
||||
int error, r;
|
||||
|
||||
if (dtp->dt_active)
|
||||
return (dt_set_errno(dtp, EINVAL));
|
||||
@ -206,11 +206,12 @@ dtrace_go(dtrace_hdl_t *dtp)
|
||||
|
||||
args.dof = dof;
|
||||
args.n_matched = 0;
|
||||
err = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args);
|
||||
r = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args);
|
||||
error = errno;
|
||||
dtrace_dof_destroy(dtp, dof);
|
||||
|
||||
if (err == -1 && (errno != ENOTTY || dtp->dt_vector == NULL))
|
||||
return (dt_set_errno(dtp, errno));
|
||||
if (r == -1 && (error != ENOTTY || dtp->dt_vector == NULL))
|
||||
return (dt_set_errno(dtp, error));
|
||||
|
||||
if (dt_ioctl(dtp, DTRACEIOC_GO, &dtp->dt_beganon) == -1) {
|
||||
if (errno == EACCES)
|
||||
|
Loading…
Reference in New Issue
Block a user