cifs: Use kzfree() to free password

Message ID 20181220113243.GA20171@kadam
State New
Headers show
Series
  • cifs: Use kzfree() to free password
Related show

Commit Message

Dan Carpenter Dec. 20, 2018, 11:32 a.m.
We should zero out the password before we free it.

Fixes: 3d6cacbb5310 ("cifs: Add DFS cache routines")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/cifs/dfs_cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paulo Alcantara Dec. 20, 2018, 1:01 p.m. | #1
Dan Carpenter <dan.carpenter@oracle.com> writes:

> We should zero out the password before we free it.
>
> Fixes: 3d6cacbb5310 ("cifs: Add DFS cache routines")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/cifs/dfs_cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
> index f74567788396..006333146a6d 100644
> --- a/fs/cifs/dfs_cache.c
> +++ b/fs/cifs/dfs_cache.c
> @@ -1130,7 +1130,7 @@ static int dup_vol(struct smb_vol *vol, struct smb_vol *new)
>  err_free_unc:
>  	kfree(new->UNC);
>  err_free_password:
> -	kfree(new->password);
> +	kzfree(new->password);
>  err_free_username:
>  	kfree(new->username);
>  	kfree(new);
> -- 
> 2.17.1

Reviewed-by: Paulo Alcantara <palcantara@suse.de>

Thanks!
Paulo
Steve French Dec. 20, 2018, 4:58 p.m. | #2
Good catch

On Thu, Dec 20, 2018 at 6:15 AM Dan Carpenter via samba-technical
<samba-technical@lists.samba.org> wrote:
>
> We should zero out the password before we free it.
>
> Fixes: 3d6cacbb5310 ("cifs: Add DFS cache routines")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  fs/cifs/dfs_cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
> index f74567788396..006333146a6d 100644
> --- a/fs/cifs/dfs_cache.c
> +++ b/fs/cifs/dfs_cache.c
> @@ -1130,7 +1130,7 @@ static int dup_vol(struct smb_vol *vol, struct smb_vol *new)
>  err_free_unc:
>         kfree(new->UNC);
>  err_free_password:
> -       kfree(new->password);
> +       kzfree(new->password);
>  err_free_username:
>         kfree(new->username);
>         kfree(new);
> --
> 2.17.1
>
>
Steve French Dec. 21, 2018, 6:19 a.m. | #3
merged into cifs-2.6.git for-next

On Thu, Dec 20, 2018 at 10:07 AM Paulo Alcantara <palcantara@suse.de> wrote:
>
> Dan Carpenter <dan.carpenter@oracle.com> writes:
>
> > We should zero out the password before we free it.
> >
> > Fixes: 3d6cacbb5310 ("cifs: Add DFS cache routines")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >  fs/cifs/dfs_cache.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
> > index f74567788396..006333146a6d 100644
> > --- a/fs/cifs/dfs_cache.c
> > +++ b/fs/cifs/dfs_cache.c
> > @@ -1130,7 +1130,7 @@ static int dup_vol(struct smb_vol *vol, struct smb_vol *new)
> >  err_free_unc:
> >       kfree(new->UNC);
> >  err_free_password:
> > -     kfree(new->password);
> > +     kzfree(new->password);
> >  err_free_username:
> >       kfree(new->username);
> >       kfree(new);
> > --
> > 2.17.1
>
> Reviewed-by: Paulo Alcantara <palcantara@suse.de>
>
> Thanks!
> Paulo

Patch

diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
index f74567788396..006333146a6d 100644
--- a/fs/cifs/dfs_cache.c
+++ b/fs/cifs/dfs_cache.c
@@ -1130,7 +1130,7 @@  static int dup_vol(struct smb_vol *vol, struct smb_vol *new)
 err_free_unc:
 	kfree(new->UNC);
 err_free_password:
-	kfree(new->password);
+	kzfree(new->password);
 err_free_username:
 	kfree(new->username);
 	kfree(new);