svn commit: r358882 - stable/11/sys/compat/linuxkpi/common/src

Hans Petter Selasky hselasky at FreeBSD.org
Wed Mar 11 08:28:59 UTC 2020


Author: hselasky
Date: Wed Mar 11 08:28:57 2020
New Revision: 358882
URL: https://svnweb.freebsd.org/changeset/base/358882

Log:
  MFC r358586:
  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
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/src/linux_compat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/src/linux_compat.c	Wed Mar 11 08:28:12 2020	(r358881)
+++ stable/11/sys/compat/linuxkpi/common/src/linux_compat.c	Wed Mar 11 08:28:57 2020	(r358882)
@@ -1493,6 +1493,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;
@@ -1510,8 +1511,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-stable mailing list