-Don't kfree NULL values.
-Return immediately where possible.
-Normalize label names.

Signed-off-by: Fabian Frederick <f...@skynet.be>
---
 fs/cifs/dir.c | 57 +++++++++++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 3db0c5f..7de6ee0 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -212,10 +212,8 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
                *oplock = REQ_OPLOCK;
 
        full_path = build_path_from_dentry(direntry);
-       if (full_path == NULL) {
-               rc = -ENOMEM;
-               goto out;
-       }
+       if (full_path == NULL)
+               return -ENOMEM;
 
        if (tcon->unix_ext && cap_unix(tcon->ses) && !tcon->broken_posix_open &&
            (CIFS_UNIX_POSIX_PATH_OPS_CAP &
@@ -269,7 +267,7 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
                        break;
 
                default:
-                       goto out;
+                       goto cifs_create_free_full_path;
                }
                /*
                 * fallthrough to retry, using older open call, this is case
@@ -302,13 +300,13 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
 
        if (!server->ops->open) {
                rc = -ENOSYS;
-               goto out;
+               goto cifs_create_free_full_path;
        }
 
        buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
        if (buf == NULL) {
                rc = -ENOMEM;
-               goto out;
+               goto cifs_create_free_full_path;
        }
 
        /*
@@ -333,7 +331,7 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
        rc = server->ops->open(xid, &oparms, oplock, buf);
        if (rc) {
                cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc);
-               goto out;
+               goto cifs_create_free_buf;
        }
 
        /*
@@ -401,13 +399,15 @@ cifs_create_set_dentry:
                         rc);
                if (server->ops->close)
                        server->ops->close(xid, tcon, fid);
-               goto out;
+               goto cifs_create_free_buf;
        }
        d_drop(direntry);
        d_add(direntry, newinode);
 
-out:
+cifs_create_free_buf:
        kfree(buf);
+
+cifs_create_free_full_path:
        kfree(full_path);
        return rc;
 }
@@ -467,7 +467,7 @@ cifs_atomic_open(struct inode *inode, struct dentry 
*direntry,
        tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb));
        if (IS_ERR(tlink)) {
                rc = PTR_ERR(tlink);
-               goto out_free_xid;
+               goto cifs_ao_free_xid;
        }
 
        tcon = tlink_tcon(tlink);
@@ -483,7 +483,7 @@ cifs_atomic_open(struct inode *inode, struct dentry 
*direntry,
 
        if (rc) {
                cifs_del_pending_open(&open);
-               goto out;
+               goto cifs_ao_put_tlink;
        }
 
        if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
@@ -494,7 +494,7 @@ cifs_atomic_open(struct inode *inode, struct dentry 
*direntry,
                if (server->ops->close)
                        server->ops->close(xid, tcon, &fid);
                cifs_del_pending_open(&open);
-               goto out;
+               goto cifs_ao_put_tlink;
        }
 
        file_info = cifs_new_fileinfo(&fid, file, tlink, oplock);
@@ -506,9 +506,10 @@ cifs_atomic_open(struct inode *inode, struct dentry 
*direntry,
                rc = -ENOMEM;
        }
 
-out:
+cifs_ao_put_tlink:
        cifs_put_tlink(tlink);
-out_free_xid:
+
+cifs_ao_free_xid:
        free_xid(xid);
        return rc;
 }
@@ -538,7 +539,7 @@ int cifs_create(struct inode *inode, struct dentry 
*direntry, umode_t mode,
        tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb));
        rc = PTR_ERR(tlink);
        if (IS_ERR(tlink))
-               goto out_free_xid;
+               goto cifs_create_free_xid;
 
        tcon = tlink_tcon(tlink);
        server = tcon->ses->server;
@@ -552,7 +553,8 @@ int cifs_create(struct inode *inode, struct dentry 
*direntry, umode_t mode,
                server->ops->close(xid, tcon, &fid);
 
        cifs_put_tlink(tlink);
-out_free_xid:
+
+cifs_create_free_xid:
        free_xid(xid);
        return rc;
 }
@@ -591,7 +593,7 @@ int cifs_mknod(struct inode *inode, struct dentry 
*direntry, umode_t mode,
        full_path = build_path_from_dentry(direntry);
        if (full_path == NULL) {
                rc = -ENOMEM;
-               goto mknod_out;
+               goto cifs_mknod_free_xid;
        }
 
        if (tcon->unix_ext) {
@@ -614,18 +616,18 @@ int cifs_mknod(struct inode *inode, struct dentry 
*direntry, umode_t mode,
                                            cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
                if (rc)
-                       goto mknod_out;
+                       goto cifs_mknod_free_full_path;
 
                rc = cifs_get_inode_info_unix(&newinode, full_path,
                                                inode->i_sb, xid);
 
                if (rc == 0)
                        d_instantiate(direntry, newinode);
-               goto mknod_out;
+               goto cifs_mknod_free_full_path;
        }
 
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
-               goto mknod_out;
+               goto cifs_mknod_free_full_path;
 
 
        cifs_dbg(FYI, "sfu compat create special file\n");
@@ -652,7 +654,7 @@ int cifs_mknod(struct inode *inode, struct dentry 
*direntry, umode_t mode,
 
        rc = CIFS_open(xid, &oparms, &oplock, buf);
        if (rc)
-               goto mknod_out;
+               goto cifs_mknod_free_full_path;
 
        /*
         * BB Do not bother to decode buf since no local inode yet to put
@@ -683,9 +685,11 @@ int cifs_mknod(struct inode *inode, struct dentry 
*direntry, umode_t mode,
 
        /* FIXME: add code here to set EAs */
 
-mknod_out:
+cifs_mknod_free_full_path:
        kfree(full_path);
        kfree(buf);
+
+cifs_mknod_free_xid:
        free_xid(xid);
        cifs_put_tlink(tlink);
        return rc;
@@ -720,7 +724,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry 
*direntry,
 
        rc = check_name(direntry);
        if (rc)
-               goto lookup_out;
+               goto cifs_lookup_put_tlink;
 
        /* can not grab the rename sem here since it would
        deadlock in the cases (beginning of sys_rename itself)
@@ -728,7 +732,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry 
*direntry,
        full_path = build_path_from_dentry(direntry);
        if (full_path == NULL) {
                rc = -ENOMEM;
-               goto lookup_out;
+               goto cifs_lookup_put_tlink;
        }
 
        if (direntry->d_inode != NULL) {
@@ -765,8 +769,9 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry 
*direntry,
                is a common return code */
        }
 
-lookup_out:
        kfree(full_path);
+
+cifs_lookup_put_tlink:
        cifs_put_tlink(tlink);
        free_xid(xid);
        return ERR_PTR(rc);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to