]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
cifs: fix memory leak when password is supplied multiple times
authorNamjae Jeon <namjae.jeon@samsung.com>
Thu, 21 Aug 2014 10:11:20 +0000 (19:11 +0900)
committerSteve French <smfrench@gmail.com>
Thu, 21 Aug 2014 17:06:57 +0000 (12:06 -0500)
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>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/connect.c

index 03ed8a09581ca0104468d1207ff0cadefd0f9390..36ca2045009bf342ef507c132921484c7eaf7ded 100644 (file)
@@ -1600,6 +1600,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
                        tmp_end++;
                        if (!(tmp_end < end && tmp_end[1] == delim)) {
                                /* No it is not. Set the password to NULL */
+                               kfree(vol->password);
                                vol->password = NULL;
                                break;
                        }
@@ -1637,6 +1638,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);