[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 9 Sep 2022 19:59:25 +0200
From: Philipp Hortmann <philipp.g.hortmann@...il.com>
To: Nam Cao <namcaov@...il.com>, forest@...ttletooquiet.net,
gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev
Subject: Re: [PATCH] staging: vt6655: fix potential memory leak
On 9/9/22 16:13, Nam Cao wrote:
> In function device_init_td0_ring, memory is allocated for member
> td_info of priv->apTD0Rings[i], with i increasing from 0. In case of
> allocation failure, the memory is freed in reversed order, with i
> decreasing to 0. However, the case i=0 is left out and thus memory is
> leaked.
>
> Modify the memory freeing loop to include the case i=0.
>
> Signed-off-by: Nam Cao <namcaov@...il.com>
> ---
> drivers/staging/vt6655/device_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
> index 3397c78b975a..a65014195fdc 100644
> --- a/drivers/staging/vt6655/device_main.c
> +++ b/drivers/staging/vt6655/device_main.c
> @@ -743,7 +743,7 @@ static int device_init_td0_ring(struct vnt_private *priv)
> return 0;
>
> err_free_desc:
> - while (--i) {
> + while (i--) {
> desc = &priv->apTD0Rings[i];
> kfree(desc->td_info);
> }
Tested-by: Philipp Hortmann <philipp.g.hortmann@...il.com>
Powered by blists - more mailing lists