Index: sys/compat/linuxkpi/common/include/linux/file.h =================================================================== --- sys/compat/linuxkpi/common/include/linux/file.h +++ sys/compat/linuxkpi/common/include/linux/file.h @@ -89,7 +89,10 @@ */ fdclose(curthread, file, fd); - /* drop extra reference */ + /* drop reference from fget_unlocked() */ + fdrop(file, curthread); + + /* drop extra reference from falloc() */ fdrop(file, curthread); } @@ -106,7 +109,10 @@ filp->_file = file; finit(file, filp->f_mode, DTYPE_DEV, filp, &linuxfileops); - /* drop the extra reference */ + /* drop the reference from fget_unlocked() */ + fput(filp); + + /* drop extra reference from falloc() */ fput(filp); } @@ -120,8 +126,6 @@ error = falloc(curthread, &file, &fd, 0); if (error) return -error; - /* drop the extra reference */ - fdrop(file, curthread); return fd; } @@ -135,8 +139,6 @@ error = falloc(curthread, &file, &fd, flags); if (error) return -error; - /* drop the extra reference */ - fdrop(file, curthread); return fd; }