diff options
Diffstat (limited to 'fs/char_dev.c')
-rw-r--r-- | fs/char_dev.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c index 262fa10e213d..700697a72618 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -386,15 +386,22 @@ static int chrdev_open(struct inode *inode, struct file *filp) | |||
386 | cdev_put(new); | 386 | cdev_put(new); |
387 | if (ret) | 387 | if (ret) |
388 | return ret; | 388 | return ret; |
389 | |||
390 | ret = -ENXIO; | ||
389 | filp->f_op = fops_get(p->ops); | 391 | filp->f_op = fops_get(p->ops); |
390 | if (!filp->f_op) { | 392 | if (!filp->f_op) |
391 | cdev_put(p); | 393 | goto out_cdev_put; |
392 | return -ENXIO; | 394 | |
393 | } | 395 | if (filp->f_op->open) { |
394 | if (filp->f_op->open) | ||
395 | ret = filp->f_op->open(inode,filp); | 396 | ret = filp->f_op->open(inode,filp); |
396 | if (ret) | 397 | if (ret) |
397 | cdev_put(p); | 398 | goto out_cdev_put; |
399 | } | ||
400 | |||
401 | return 0; | ||
402 | |||
403 | out_cdev_put: | ||
404 | cdev_put(p); | ||
398 | return ret; | 405 | return ret; |
399 | } | 406 | } |
400 | 407 | ||