Skip to contentSkip to conversation

cifs: fix memory leak when password is supplied multiple times

PATCH Applied Namjae Jeon 2 participants 2 messages Aug 20, 2014 – Aug 21, 2014

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

PATCH 5/7 cifs: fix memory leak when password is supplied multiple times

Unlikely but possible. When password is supplied multiple times, we have to free the previous allocation.

---
 fs/cifs/connect.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/cifs/connect.c +2 -0
index b4b6d10..91512fd 100644
@@ -1583,6 +1583,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 			 * Check if this is a case where the  password
 			 * starts with a delimiter
 			 */
+			kfree(vol->password);
 			tmp_end = strchr(data, '=');
 			tmp_end++;
 			if (!(tmp_end < end && tmp_end[1] == delim)) {
@@ -1624,6 +1625,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 					options = end;
 			}
 
+			kfree(vol->password);
 			/* Now build new password string */
 			temp_len = strlen(value);
 			vol->password = kzalloc(temp_len+1, GFP_KERNEL);
Signature · 1 line
1.7.7
Applied
#1 lore raw

merged into cifs-2.6.git for-next

Quoted 32 lines · Namjae Jeon

Unlikely but possible. When password is supplied multiple times, we have to free the previous allocation.

---
 fs/cifs/connect.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/cifs/connect.c +2 -1
index b4b6d10..91512fd 100644
@@ -1583,6 +1583,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
                         * Check if this is a case where the  password
                         * starts with a delimiter
                         */
+                       kfree(vol->password);
                        tmp_end = strchr(data, '=');
                        tmp_end++;
                        if (!(tmp_end < end && tmp_end[1] == delim)) {
@@ -1624,6 +1625,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
                                        options = end;
                        }
 
+                       kfree(vol->password);
                        /* Now build new password string */
                        temp_len = strlen(value);
                        vol->password = kzalloc(temp_len+1, GFP_KERNEL);
--

1.7.7

Signature · 3 lines
Thanks,

Steve