... and the same for gadgetfs
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 8 Jan 2012 20:59:45 +0000 (15:59 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 9 Jan 2012 01:18:50 +0000 (20:18 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/usb/gadget/inode.c

index 6ccae2707e596c3f24d5705495264f0dcfa4f31b..6b7ea25af0fe7f647f193a52b817375566dd8fcb 100644 (file)
@@ -2035,7 +2035,6 @@ static int
 gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
 {
        struct inode    *inode;
-       struct dentry   *d;
        struct dev_data *dev;
 
        if (the_device)
@@ -2058,24 +2057,27 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
                        NULL, &simple_dir_operations,
                        S_IFDIR | S_IRUGO | S_IXUGO);
        if (!inode)
-               goto enomem0;
+               goto Enomem;
        inode->i_op = &simple_dir_inode_operations;
-       if (!(d = d_alloc_root (inode)))
-               goto enomem1;
-       sb->s_root = d;
+       if (!(sb->s_root = d_alloc_root (inode))) {
+               iput(inode);
+               goto Enomem;
+       }
 
        /* the ep0 file is named after the controller we expect;
         * user mode code can use it for sanity checks, like we do.
         */
        dev = dev_new ();
        if (!dev)
-               goto enomem2;
+               goto Enomem;
 
        dev->sb = sb;
        if (!gadgetfs_create_file (sb, CHIP,
                                dev, &dev_init_operations,
-                               &dev->dentry))
-               goto enomem3;
+                               &dev->dentry)) {
+               put_dev(dev);
+               goto Enomem;
+       }
 
        /* other endpoint files are available after hardware setup,
         * from binding to a controller.
@@ -2083,13 +2085,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
        the_device = dev;
        return 0;
 
-enomem3:
-       put_dev (dev);
-enomem2:
-       dput (d);
-enomem1:
-       iput (inode);
-enomem0:
+Enomem:
        return -ENOMEM;
 }