cifs: Fix memory leak in cifs_hardlink()
authorChristian Engelmayer <cengelma@gmx.at>
Sat, 11 Jan 2014 00:57:22 +0000 (01:57 +0100)
committerSteve French <smfrench@gmail.com>
Mon, 20 Jan 2014 05:58:18 +0000 (23:58 -0600)
Fix a potential memory leak in the cifs_hardlink() error handling path.
Detected by Coverity: CID 728510, CID 728511.

Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/link.c

index 92aee08..28bc8ee 100644 (file)
@@ -438,8 +438,10 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
        else {
                server = tcon->ses->server;
-               if (!server->ops->create_hardlink)
-                       return -ENOSYS;
+               if (!server->ops->create_hardlink) {
+                       rc = -ENOSYS;
+                       goto cifs_hl_exit;
+               }
                rc = server->ops->create_hardlink(xid, tcon, from_name, to_name,
                                                  cifs_sb);
                if ((rc == -EIO) || (rc == -EINVAL))