Skip to content

Commit

Permalink
staging: vt6655: fix potential memory leak
Browse files Browse the repository at this point in the history
[ Upstream commit c8ff915 ]

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>
  • Loading branch information
covanam authored and gregkh committed Oct 21, 2022
1 parent dc52b73 commit cfdf139
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/vt6655/device_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,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);
}
Expand Down

0 comments on commit cfdf139

Please sign in to comment.