]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
radeon: avoid double free in ci_dpm_init()
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Thu, 13 Apr 2023 15:12:28 +0000 (08:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:37:12 +0000 (08:37 +0200)
commit3e789aee218bf3547f9bed1ea848a789008c3b35
treeea8af128635fd509e80d78d1eadc994c663f134b
parentbc5b57a23087b9b416ccbeadea77b2ba855671bd
radeon: avoid double free in ci_dpm_init()

[ Upstream commit 20c3dffdccbd494e0dd631d1660aeecbff6775f2 ]

Several calls to ci_dpm_fini() will attempt to free resources that
either have been freed before or haven't been allocated yet. This
may lead to undefined or dangerous behaviour.

For instance, if r600_parse_extended_power_table() fails, it might
call r600_free_extended_power_table() as will ci_dpm_fini() later
during error handling.

Fix this by only freeing pointers to objects previously allocated.

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

Fixes: cc8dbbb4f62a ("drm/radeon: add dpm support for CI dGPUs (v2)")
Co-developed-by: Natalia Petrova <n.petrova@fintech.ru>
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/radeon/ci_dpm.c