From owner-svn-src-head@freebsd.org Fri Sep 23 06:51:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10C95BE5B87; Fri, 23 Sep 2016 06:51:48 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D663EC39; Fri, 23 Sep 2016 06:51:47 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8N6plhB015487; Fri, 23 Sep 2016 06:51:47 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8N6pllK015486; Fri, 23 Sep 2016 06:51:47 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201609230651.u8N6pllK015486@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Fri, 23 Sep 2016 06:51:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306226 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2016 06:51:48 -0000 Author: mjg Date: Fri Sep 23 06:51:46 2016 New Revision: 306226 URL: https://svnweb.freebsd.org/changeset/base/306226 Log: fd: fix up fgetvp_rights after r306184 fget_cap_locked returns a referenced file, but the fgetvp_rights does not need it. Instead, due to the filedesc lock being held, it can ref the vnode after the file was looked up. Fix up fget_cap_locked to be consistent with other _locked helpers and not ref the file. This plugs a leak introduced in r306184. Pointy hat to: mjg, oshogbo Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Sep 23 04:53:47 2016 (r306225) +++ head/sys/kern/kern_descrip.c Fri Sep 23 06:51:46 2016 (r306226) @@ -2469,7 +2469,6 @@ fget_cap_locked(struct filedesc *fdp, in if (havecapsp != NULL) filecaps_copy(&fde->fde_caps, havecapsp, true); - fhold(fde->fde_file); *fpp = fde->fde_file; error = 0; @@ -2511,6 +2510,8 @@ fget_cap(struct thread *td, int fd, cap_ get_locked: FILEDESC_SLOCK(fdp); error = fget_cap_locked(fdp, fd, needrightsp, fpp, havecapsp); + if (error == 0) + fhold(*fpp); FILEDESC_SUNLOCK(fdp); return (error);