diff options
author | Nam Cao <namcaov@gmail.com> | 2022-09-09 16:13:39 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-10-26 13:22:56 +0200 |
commit | 16a45e78a687eb6c69acc4e62b94b6508b0bfbda (patch) | |
tree | 38e9ceea2913d7d033a7cedc9f0be2b9e03cfb3f | |
parent | 3376a0cf138dfc90b449fde541ca228a33e1c143 (diff) | |
download | linux-stable-16a45e78a687eb6c69acc4e62b94b6508b0bfbda.tar.gz linux-stable-16a45e78a687eb6c69acc4e62b94b6508b0bfbda.tar.bz2 linux-stable-16a45e78a687eb6c69acc4e62b94b6508b0bfbda.zip |
staging: vt6655: fix potential memory leak
[ Upstream commit c8ff91535880d41b49699b3829fb6151942de29e ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/staging/vt6655/device_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c1f9b263129e..18284c427b7e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -670,7 +670,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); } |