]> git.baikalelectronics.ru Git - kernel.git/commit
drm/amdgpu: Fix resource leak on probe error path
authorJiri Kosina <jkosina@suse.cz>
Thu, 24 Jun 2021 11:20:21 +0000 (13:20 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 26 Jul 2021 16:42:49 +0000 (12:42 -0400)
commit30c66756917b9c73314e42520bb808acca1b43cf
treede9bc19cd67eda340df793984f93e13476be3ab2
parentce081bbfc21f6f738849857e74412a95b10e55c9
drm/amdgpu: Fix resource leak on probe error path

This reverts commit b71d06f6bbc2f42c5692fc9180fe918d80fae817.

It is not true (as stated in the reverted commit changelog) that we never
unmap the BAR on failure; it actually does happen properly on
amdgpu_driver_load_kms() -> amdgpu_driver_unload_kms() ->
amdgpu_device_fini() error path.

What's worse, this commit actually completely breaks resource freeing on
probe failure (like e.g. failure to load microcode), as
amdgpu_driver_unload_kms() notices adev->rmmio being NULL and bails too
early, leaving all the resources that'd normally be freed in
amdgpu_acpi_fini() and amdgpu_device_fini() still hanging around, leading
to all sorts of oopses when someone tries to, for example, access the
sysfs and procfs resources which are still around while the driver is
gone.

Fixes: b71d06f6bbc2 ("drm/amdgpu: unmap register bar on device init failure")
Reported-by: Vojtech Pavlik <vojtech@ucw.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c