Skip to content

Commit

Permalink
[PATCH] tidy up chrdev_open
Browse files Browse the repository at this point in the history
Use a single goto label for chrdev_put + return error cases.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Oct 23, 2008
1 parent ca30bc9 commit a518ab9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions fs/char_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,22 @@ static int chrdev_open(struct inode *inode, struct file *filp)
cdev_put(new);
if (ret)
return ret;

ret = -ENXIO;
filp->f_op = fops_get(p->ops);
if (!filp->f_op) {
cdev_put(p);
return -ENXIO;
}
if (filp->f_op->open)
if (!filp->f_op)
goto out_cdev_put;

if (filp->f_op->open) {
ret = filp->f_op->open(inode,filp);
if (ret)
cdev_put(p);
if (ret)
goto out_cdev_put;
}

return 0;

out_cdev_put:
cdev_put(p);
return ret;
}

Expand Down

0 comments on commit a518ab9

Please sign in to comment.