Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Sep 2016 06:51:47 +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: r306226 - head/sys/kern
Message-ID:  <201609230651.u8N6pllK015486@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609230651.u8N6pllK015486>