diff mbox

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

Message ID 003801cfbc63$08767980$19636c80$@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Namjae Jeon Aug. 20, 2014, 10:39 a.m. UTC
Unlikely but possible. When password is supplied multiple times, we have
to free the previous allocation.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
---
 fs/cifs/connect.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Steve French Aug. 21, 2014, 12:10 a.m. UTC | #1
merged into cifs-2.6.git for-next

On Wed, Aug 20, 2014 at 5:39 AM, Namjae Jeon <namjae.jeon@samsung.com> wrote:
> Unlikely but possible. When password is supplied multiple times, we have
> to free the previous allocation.
>
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
> ---
>  fs/cifs/connect.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index b4b6d10..91512fd 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -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
>
diff mbox

Patch

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index b4b6d10..91512fd 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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);