Re: [PATCH] fs/cifs/cifs_dfs_ref.c: fix potential memory leakage

From: Jeff Layton
Date: Tue Jan 22 2013 - 20:35:59 EST


On Tue, 22 Jan 2013 19:20:58 -0500
Cong Ding <dinggnu@xxxxxxxxx> wrote:

> When it goes to error through line 144, the memory allocated to *devname is
> not freed, and the caller doesn't free it either in line 250. So we free the
> memroy of *devname in function cifs_compose_mount_options() when it goes to
> error.
>
> Signed-off-by: Cong Ding <dinggnu@xxxxxxxxx>
> ---
> fs/cifs/cifs_dfs_ref.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
> index ce5cbd7..210fce2 100644
> --- a/fs/cifs/cifs_dfs_ref.c
> +++ b/fs/cifs/cifs_dfs_ref.c
> @@ -226,6 +226,8 @@ compose_mount_options_out:
> compose_mount_options_err:
> kfree(mountdata);
> mountdata = ERR_PTR(rc);
> + kfree(*devname);
> + *devname = NULL;
> goto compose_mount_options_out;
> }
>

Nice catch. Looks correct to me. Should this also go to stable?

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/