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 <[email protected]> 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); _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "[email protected]"
