--- x/fs/kernfs/file.c +++ y/fs/kernfs/file.c @@ -775,9 +775,11 @@ static int kernfs_fop_release(struct ino if (kn->flags & KERNFS_HAS_RELEASE) { struct mutex *mutex; + mutex_lock(&of->mutex); mutex = kernfs_open_file_mutex_lock(kn); kernfs_release_file(kn, of); mutex_unlock(mutex); + mutex_unlock(&of->mutex); } kernfs_unlink_open_file(kn, of, false);