]> git.baikalelectronics.ru Git - kernel.git/commit
staging: vt6655: fix potential memory leak
authorNam Cao <namcaov@gmail.com>
Fri, 9 Sep 2022 14:13:39 +0000 (16:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:56 +0000 (13:22 +0200)
commit3237869547d72a70d462bffa38856ccec222ef8d
tree38e9ceea2913d7d033a7cedc9f0be2b9e03cfb3f
parente245f9f30062bc84c5da108a76130f1ee728df2e
staging: vt6655: fix potential memory leak

[ Upstream commit e704dc8a370ce3f8b5b96f327f811f965785620e ]

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>
drivers/staging/vt6655/device_main.c