mqueuefs: fix struct file leak

In some error cases we previously leaked a stuct file.

Submitted by:	mjg, markj
This commit is contained in:
Ed Maste 2019-07-23 20:59:36 +00:00
parent 0642bc1cbb
commit 051e692a99

View File

@ -2283,13 +2283,14 @@ sys_kmq_timedreceive(struct thread *td, struct kmq_timedreceive_args *uap)
if (uap->abs_timeout != NULL) { if (uap->abs_timeout != NULL) {
error = copyin(uap->abs_timeout, &ets, sizeof(ets)); error = copyin(uap->abs_timeout, &ets, sizeof(ets));
if (error != 0) if (error != 0)
return (error); goto out;
abs_timeout = &ets; abs_timeout = &ets;
} else } else
abs_timeout = NULL; abs_timeout = NULL;
waitok = !(fp->f_flag & O_NONBLOCK); waitok = !(fp->f_flag & O_NONBLOCK);
error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len, error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len,
uap->msg_prio, waitok, abs_timeout); uap->msg_prio, waitok, abs_timeout);
out:
fdrop(fp, td); fdrop(fp, td);
return (error); return (error);
} }
@ -2309,13 +2310,14 @@ sys_kmq_timedsend(struct thread *td, struct kmq_timedsend_args *uap)
if (uap->abs_timeout != NULL) { if (uap->abs_timeout != NULL) {
error = copyin(uap->abs_timeout, &ets, sizeof(ets)); error = copyin(uap->abs_timeout, &ets, sizeof(ets));
if (error != 0) if (error != 0)
return (error); goto out;
abs_timeout = &ets; abs_timeout = &ets;
} else } else
abs_timeout = NULL; abs_timeout = NULL;
waitok = !(fp->f_flag & O_NONBLOCK); waitok = !(fp->f_flag & O_NONBLOCK);
error = mqueue_send(mq, uap->msg_ptr, uap->msg_len, error = mqueue_send(mq, uap->msg_ptr, uap->msg_len,
uap->msg_prio, waitok, abs_timeout); uap->msg_prio, waitok, abs_timeout);
out:
fdrop(fp, td); fdrop(fp, td);
return (error); return (error);
} }
@ -2834,7 +2836,7 @@ freebsd32_kmq_timedreceive(struct thread *td,
if (uap->abs_timeout != NULL) { if (uap->abs_timeout != NULL) {
error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); error = copyin(uap->abs_timeout, &ets32, sizeof(ets32));
if (error != 0) if (error != 0)
return (error); goto out;
CP(ets32, ets, tv_sec); CP(ets32, ets, tv_sec);
CP(ets32, ets, tv_nsec); CP(ets32, ets, tv_nsec);
abs_timeout = &ets; abs_timeout = &ets;
@ -2843,6 +2845,7 @@ freebsd32_kmq_timedreceive(struct thread *td,
waitok = !(fp->f_flag & O_NONBLOCK); waitok = !(fp->f_flag & O_NONBLOCK);
error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len, error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len,
uap->msg_prio, waitok, abs_timeout); uap->msg_prio, waitok, abs_timeout);
out:
fdrop(fp, td); fdrop(fp, td);
return (error); return (error);
} }