Skip to contentSkip to conversation

cifs: Fix memory leak in cifs_hardlink()

PATCH Applied Christian Engelmayer 2 participants 2 messages Jan 11, 2014 – Jan 13, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Fix memory leak in cifs_hardlink()

Fix a potential memory leak in the cifs_hardlink() error handling path. Detected by Coverity: CID 728510, CID 728511.

---
 fs/cifs/link.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/link.c +4 -2
index 92aee08..28bc8ee 100644
@@ -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))
Signature · 1 line
1.8.3.2
Applied
#1 lore raw

Merged into cifs-2.6.git

Quoted 27 lines · Christian Engelmayer

Fix a potential memory leak in the cifs_hardlink() error handling path. Detected by Coverity: CID 728510, CID 728511.

---
 fs/cifs/link.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/link.c +4 -3
index 92aee08..28bc8ee 100644
@@ -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))
--

1.8.3.2

Signature · 3 lines
Thanks,

Steve