From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
To: Nam Cao <namcaov@gmail.com>,
forest@alittletooquiet.net, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: vt6655: fix potential memory leak
Date: Fri, 9 Sep 2022 19:59:25 +0200 [thread overview]
Message-ID: <499af3df-5fed-91b5-9006-0ce3bac41c1d@gmail.com> (raw)
In-Reply-To: <20220909141338.19343-1-namcaov@gmail.com>
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@gmail.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@gmail.com>
next prev parent reply other threads:[~2022-09-09 17:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 14:13 [PATCH] staging: vt6655: fix potential memory leak Nam Cao
2022-09-09 14:42 ` Nam Cao
2022-09-12 14:17 ` Dan Carpenter
2022-09-12 14:53 ` Dan Carpenter
2022-09-09 17:59 ` Philipp Hortmann [this message]
2022-09-12 13:25 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=499af3df-5fed-91b5-9006-0ce3bac41c1d@gmail.com \
--to=philipp.g.hortmann@gmail.com \
--cc=forest@alittletooquiet.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=namcaov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.