drm/amdgpu: Fix potential double free and null pointer dereference
authorLiang He <windhl@126.com>
Tue, 22 Nov 2022 04:28:49 +0000 (12:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:33:03 +0000 (13:33 +0100)
commitb9f8ed9b01c40167bf46f6c25391a875b41c60b5
treebdcc17636d99a3cd86bdfd4c3cbd1b7699478a09
parent3759ae6600e401297a51ebcfe9a7c6a4a8aa23b7
drm/amdgpu: Fix potential double free and null pointer dereference

[ Upstream commit dfd0287bd3920e132a8dae2a0ec3d92eaff5f2dd ]

In amdgpu_get_xgmi_hive(), we should not call kfree() after
kobject_put() as the PUT will call kfree().

In amdgpu_device_ip_init(), we need to check the returned *hive*
which can be NULL before we dereference it.

Signed-off-by: Liang He <windhl@126.com>
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c