Date: Wed, 11 Mar 2020 08:28:12 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r358881 - stable/12/sys/compat/linuxkpi/common/src Message-ID: <202003110828.02B8SCMK065416@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Wed Mar 11 08:28:12 2020 New Revision: 358881 URL: https://svnweb.freebsd.org/changeset/base/358881 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@pensando.io> Reviewed by: kib@ PR: 244572 Sponsored by: Mellanox Technologies Modified: stable/12/sys/compat/linuxkpi/common/src/linux_compat.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- stable/12/sys/compat/linuxkpi/common/src/linux_compat.c Wed Mar 11 08:26:52 2020 (r358880) +++ stable/12/sys/compat/linuxkpi/common/src/linux_compat.c Wed Mar 11 08:28:12 2020 (r358881) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003110828.02B8SCMK065416>