Skip to contentSkip to conversation

CIFS: Fix memory leaks in SMB2_open

PATCH Applied Pavel Shilovsky 3 participants 3 messages May 24, 2014 – May 27, 2014 1 message not in the archive

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

PATCH 1/1 CIFS: Fix memory leaks in SMB2_open

---
 fs/cifs/smb2pdu.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +6 -1
index b0037b6..b0b260d 100644
@@ -1097,6 +1097,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 	int rc = 0;
 	unsigned int num_iovecs = 2;
 	__u32 file_attributes = 0;
+	char *dhc_buf = NULL, *lc_buf = NULL;
 
 	cifs_dbg(FYI, "create/open\n");
 
@@ -1163,6 +1164,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 			kfree(copy_path);
 			return rc;
 		}
+		lc_buf = iov[num_iovecs-1].iov_base;
 	}
 
 	if (*oplock == SMB2_OPLOCK_LEVEL_BATCH) {
@@ -1177,9 +1179,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 		if (rc) {
 			cifs_small_buf_release(req);
 			kfree(copy_path);
-			kfree(iov[num_iovecs-1].iov_base);
+			kfree(lc_buf);
 			return rc;
 		}
+		dhc_buf = iov[num_iovecs-1].iov_base;
 	}
 
 	rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
@@ -1211,6 +1214,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 		*oplock = rsp->OplockLevel;
 creat_exit:
 	kfree(copy_path);
+	kfree(lc_buf);
+	kfree(dhc_buf);
 	free_rsp_buf(resp_buftype, rsp);
 	return rc;
 }
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1400935322-5157-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org

Reviewed-by
#2 lore raw

Looks correct.

Quoted 54 lines · Pavel Shilovsky
---
 fs/cifs/smb2pdu.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +6 -2
index b0037b6..b0b260d 100644
@@ -1097,6 +1097,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
        int rc = 0;
        unsigned int num_iovecs = 2;
        __u32 file_attributes = 0;
+       char *dhc_buf = NULL, *lc_buf = NULL;
 
        cifs_dbg(FYI, "create/open\n");
 
@@ -1163,6 +1164,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                        kfree(copy_path);
                        return rc;
                }
+               lc_buf = iov[num_iovecs-1].iov_base;
        }
 
        if (*oplock == SMB2_OPLOCK_LEVEL_BATCH) {
@@ -1177,9 +1179,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                if (rc) {
                        cifs_small_buf_release(req);
                        kfree(copy_path);
-                       kfree(iov[num_iovecs-1].iov_base);
+                       kfree(lc_buf);
                        return rc;
                }
+               dhc_buf = iov[num_iovecs-1].iov_base;
        }
 
        rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
@@ -1211,6 +1214,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                *oplock = rsp->OplockLevel;
 creat_exit:
        kfree(copy_path);
+       kfree(lc_buf);
+       kfree(dhc_buf);
        free_rsp_buf(resp_buftype, rsp);
        return rc;
 }
--

1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#3 lore raw

merged into cifs-2.6.git for-next

Quoted 63 lines · Shirish Pargaonkar

Looks correct.

Quoted 50 lines · Pavel Shilovsky
---
 fs/cifs/smb2pdu.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +6 -2
index b0037b6..b0b260d 100644
@@ -1097,6 +1097,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
        int rc = 0;
        unsigned int num_iovecs = 2;
        __u32 file_attributes = 0;
+       char *dhc_buf = NULL, *lc_buf = NULL;
 
        cifs_dbg(FYI, "create/open\n");
 
@@ -1163,6 +1164,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                        kfree(copy_path);
                        return rc;
                }
+               lc_buf = iov[num_iovecs-1].iov_base;
        }
 
        if (*oplock == SMB2_OPLOCK_LEVEL_BATCH) {
@@ -1177,9 +1179,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                if (rc) {
                        cifs_small_buf_release(req);
                        kfree(copy_path);
-                       kfree(iov[num_iovecs-1].iov_base);
+                       kfree(lc_buf);
                        return rc;
                }
+               dhc_buf = iov[num_iovecs-1].iov_base;
        }
 
        rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
@@ -1211,6 +1214,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                *oplock = rsp->OplockLevel;
 creat_exit:
        kfree(copy_path);
+       kfree(lc_buf);
+       kfree(dhc_buf);
        free_rsp_buf(resp_buftype, rsp);
        return rc;
 }
--

1.7.10.4

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Thanks,

Steve