Commit 231f2371 authored by Nam Cao's avatar Nam Cao Committed by Jialin Zhang
Browse files

staging: vt6655: fix potential memory leak

stable inclusion
from stable-v5.10.150
commit 1b3cebeca99e8e0aa4fa57faac8dbf41e967317a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0XA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1b3cebeca99e8e0aa4fa57faac8dbf41e967317a



--------------------------------

[ Upstream commit c8ff9153 ]

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>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent 4b88f8bc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment