From: Christoph Hellwig Date: Mon, 11 Aug 2008 13:34:22 +0000 (+0200) Subject: [PATCH] tidy up chrdev_open X-Git-Tag: v2.6.28-rc1~24^2~32 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=a518ab9329041411526ab8e05edfda7e2715244f;p=linux-2.6-omap-h63xx.git [PATCH] tidy up chrdev_open Use a single goto label for chrdev_put + return error cases. Signed-off-by: Christoph Hellwig Signed-off-by: Al Viro --- diff --git a/fs/char_dev.c b/fs/char_dev.c index 262fa10e213..700697a7261 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) 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; }