Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16a45e78 authored by Nam Cao's avatar Nam Cao Committed by Greg Kroah-Hartman
Browse files

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: default avatarPhilipp Hortmann <philipp.g.hortmann@gmail.com>
Signed-off-by: default avatarNam Cao <namcaov@gmail.com>
Link: https://lore.kernel.org/r/20220909141338.19343-1-namcaov@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 3376a0cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
	}