--- x/fs/open.c +++ y/fs/open.c @@ -952,7 +952,11 @@ static int do_dentry_open(struct file *f if (!open) open = f->f_op->open; if (open) { + error = -ENODEV; + if (!atomic_inc_not_zero(&inode->i_count)) + goto cleanup_all; error = open(inode, f); + iput(inode); if (error) goto cleanup_all; }