Skip to content

Commit a518ab9

Browse files
Christoph HellwigAl Viro
Christoph Hellwig
authored and
Al Viro
committedOct 23, 2008
[PATCH] tidy up chrdev_open
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]>
1 parent ca30bc9 commit a518ab9

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed
 

‎fs/char_dev.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,22 @@ static int chrdev_open(struct inode *inode, struct file *filp)
386386
cdev_put(new);
387387
if (ret)
388388
return ret;
389+
390+
ret = -ENXIO;
389391
filp->f_op = fops_get(p->ops);
390-
if (!filp->f_op) {
391-
cdev_put(p);
392-
return -ENXIO;
393-
}
394-
if (filp->f_op->open)
392+
if (!filp->f_op)
393+
goto out_cdev_put;
394+
395+
if (filp->f_op->open) {
395396
ret = filp->f_op->open(inode,filp);
396-
if (ret)
397-
cdev_put(p);
397+
if (ret)
398+
goto out_cdev_put;
399+
}
400+
401+
return 0;
402+
403+
out_cdev_put:
404+
cdev_put(p);
398405
return ret;
399406
}
400407

0 commit comments

Comments
 (0)
Please sign in to comment.