Skip to content

Commit d47255d

Browse files
Jiri Kosinaalexdeucher
authored andcommitted
drm/amdgpu: Fix resource leak on probe error path
This reverts commit 4192f7b. 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: 4192f7b ("drm/amdgpu: unmap register bar on device init failure") Reported-by: Vojtech Pavlik <[email protected]> Signed-off-by: Jiri Kosina <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent ff11764 commit d47255d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,13 +3504,13 @@ int amdgpu_device_init(struct amdgpu_device *adev,
35043504
r = amdgpu_device_get_job_timeout_settings(adev);
35053505
if (r) {
35063506
dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n");
3507-
goto failed_unmap;
3507+
return r;
35083508
}
35093509

35103510
/* early init functions */
35113511
r = amdgpu_device_ip_early_init(adev);
35123512
if (r)
3513-
goto failed_unmap;
3513+
return r;
35143514

35153515
/* doorbell bar mapping and doorbell index init*/
35163516
amdgpu_device_doorbell_init(adev);
@@ -3736,10 +3736,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
37363736
failed:
37373737
amdgpu_vf_error_trans_all(adev);
37383738

3739-
failed_unmap:
3740-
iounmap(adev->rmmio);
3741-
adev->rmmio = NULL;
3742-
37433739
return r;
37443740
}
37453741

0 commit comments

Comments
 (0)