aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/vt6655
diff options
context:
space:
mode:
authorNam Cao <namcaov@gmail.com>2022-09-09 16:13:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-09-11 13:57:11 +0200
commitc8ff91535880d41b49699b3829fb6151942de29e (patch)
treee90e392cd19614c30b2a7f8e33586f95c0a7fcf2 /drivers/staging/vt6655
parentstaging: r8188eu: make c2h_evt_read() static (diff)
downloadlinux-dev-c8ff91535880d41b49699b3829fb6151942de29e.tar.xz
linux-dev-c8ff91535880d41b49699b3829fb6151942de29e.zip
staging: vt6655: fix potential memory leak
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. Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> Signed-off-by: Nam Cao <namcaov@gmail.com> Link: https://lore.kernel.org/r/20220909141338.19343-1-namcaov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vt6655')
-rw-r--r--drivers/staging/vt6655/device_main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 0d8876278953..04d737012cef 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -742,7 +742,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);
}