From 1e2d8c9d67bc3fa3bf3a560b9b8eac1745104048 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 4 Nov 2011 03:39:31 +0000 Subject: [PATCH] Move the cleanup of f_cdevpriv when the reference count of a devfs file descriptor drops to zero out of _fdrop() and into devfs_close_f() as it is only relevant for devfs file descriptors. Reviewed by: kib MFC after: 1 week --- sys/fs/devfs/devfs_vnops.c | 7 +++++++ sys/kern/kern_descrip.c | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 41bc0b80c9ce..eb154b117200 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -604,6 +604,13 @@ devfs_close_f(struct file *fp, struct thread *td) td->td_fpop = fp; error = vnops.fo_close(fp, td); td->td_fpop = fpop; + + /* + * The f_cdevpriv cannot be assigned non-NULL value while we + * are destroying the file. + */ + if (fp->f_cdevpriv != NULL) + devfs_fpdrop(fp); return (error); } diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 8b3e20e06914..72e42e5eae31 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2575,12 +2575,6 @@ _fdrop(struct file *fp, struct thread *td) panic("fdrop: count %d", fp->f_count); if (fp->f_ops != &badfileops) error = fo_close(fp, td); - /* - * The f_cdevpriv cannot be assigned non-NULL value while we - * are destroying the file. - */ - if (fp->f_cdevpriv != NULL) - devfs_fpdrop(fp); atomic_subtract_int(&openfiles, 1); crfree(fp->f_cred); uma_zfree(file_zone, fp);