Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Mar 2020 15:49:34 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r358586 - head/sys/compat/linuxkpi/common/src
Message-ID:  <202003031549.023FnYCR059046@repo.freebsd.org>

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



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