]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: vt6655: fix potential memory leak
authorNam Cao <namcaov@gmail.com>
Fri, 9 Sep 2022 14:13:39 +0000 (16:13 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 24 Nov 2022 13:25:03 +0000 (14:25 +0100)
BugLink: https://bugs.launchpad.net/bugs/1996825
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/staging/vt6655/device_main.c

index 43e32360b6d93c399f0fcf51235288951ddc228b..775537b243aabcd3fd283d3f13eaa665ff73c32e 100644 (file)
@@ -676,7 +676,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);
        }