svn commit: r358586 - head/sys/compat/linuxkpi/common/src

Hans Petter Selasky hselasky at FreeBSD.org
Tue Mar 3 15:49:35 UTC 2020


Author: hselasky
Date: Tue Mar  3 15:49:34 2020
New Revision: 358586
URL: https://svnweb.freebsd.org/changeset/base/358586

Log:
  When closing a LinuxKPI file always use the real release function to avoid
  resource leakage when destroying a LinuxKPI character device.
  
  Submitted by:	Andrew Boyer <aboyer at pensando.io>
  Reviewed by:	kib@
  PR:		244572
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/src/linux_compat.c

Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_compat.c	Tue Mar  3 15:33:43 2020	(r358585)
+++ head/sys/compat/linuxkpi/common/src/linux_compat.c	Tue Mar  3 15:49:34 2020	(r358586)
@@ -1490,6 +1490,7 @@ static int
 linux_file_close(struct file *file, struct thread *td)
 {
 	struct linux_file *filp;
+	int (*release)(struct inode *, struct linux_file *);
 	const struct file_operations *fop;
 	struct linux_cdev *ldev;
 	int error;
@@ -1507,8 +1508,13 @@ linux_file_close(struct file *file, struct thread *td)
 	linux_set_current(td);
 	linux_poll_wait_dequeue(filp);
 	linux_get_fop(filp, &fop, &ldev);
-	if (fop->release != NULL)
-		error = -OPW(file, td, fop->release(filp->f_vnode, filp));
+	/*
+	 * Always use the real release function, if any, to avoid
+	 * leaking device resources:
+	 */
+	release = filp->f_op->release;
+	if (release != NULL)
+		error = -OPW(file, td, release(filp->f_vnode, filp));
 	funsetown(&filp->f_sigio);
 	if (filp->f_vnode != NULL)
 		vdrop(filp->f_vnode);


More information about the svn-src-head mailing list