diff --git a/fs/file_table.c b/fs/file_table.c index bfab973c6c5ba8ba316302079bfc74911bb1a6b5..01e4c1e8e6b6badc81a659a8616694dc677310a7 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -247,8 +247,10 @@ static void __fput(struct file *file) file->f_op->release(inode, file); security_file_free(file); ima_file_free(file); - if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL)) + if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL && + !(file->f_mode & FMODE_PATH))) { cdev_put(inode->i_cdev); + } fops_put(file->f_op); put_pid(file->f_owner.pid); file_sb_list_del(file);