Date: Wed, 23 Sep 2015 12:45:08 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288145 - head/sys/kern Message-ID: <201509231245.t8NCj8RL029754@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Wed Sep 23 12:45:08 2015 New Revision: 288145 URL: https://svnweb.freebsd.org/changeset/base/288145 Log: kqueue: simplify kern_kqueue by not refing/unrefing creds too early No functional changes. Modified: head/sys/kern/kern_event.c Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Wed Sep 23 07:44:07 2015 (r288144) +++ head/sys/kern/kern_event.c Wed Sep 23 12:45:08 2015 (r288145) @@ -759,28 +759,25 @@ kern_kqueue(struct thread *td, int flags struct filedesc *fdp; struct kqueue *kq; struct file *fp; - struct proc *p; struct ucred *cred; int fd, error; - p = td->td_proc; + fdp = td->td_proc->p_fd; cred = td->td_ucred; - crhold(cred); - if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_KQUEUES))) { - crfree(cred); + if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_KQUEUES))) return (ENOMEM); - } - fdp = p->p_fd; error = falloc_caps(td, &fp, &fd, flags, fcaps); - if (error) - goto done2; + if (error != 0) { + chgkqcnt(cred->cr_ruidinfo, -1, 0); + return (error); + } /* An extra reference on `fp' has been held for us by falloc(). */ kq = malloc(sizeof *kq, M_KQUEUE, M_WAITOK | M_ZERO); kqueue_init(kq); kq->kq_fdp = fdp; - kq->kq_cred = cred; + kq->kq_cred = crhold(cred); FILEDESC_XLOCK(fdp); TAILQ_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); @@ -790,12 +787,7 @@ kern_kqueue(struct thread *td, int flags fdrop(fp, td); td->td_retval[0] = fd; -done2: - if (error != 0) { - chgkqcnt(cred->cr_ruidinfo, -1, 0); - crfree(cred); - } - return (error); + return (0); } #ifndef _SYS_SYSPROTO_H_
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509231245.t8NCj8RL029754>