• Jiri Kosina's avatar
    drm/amdgpu: Fix resource leak on probe error path · d47255d3
    Jiri Kosina authored
    This reverts commit 4192f7b5.
    
    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: 4192f7b5 ("drm/amdgpu: unmap register bar on device init failure")
    Reported-by: default avatarVojtech Pavlik <vojtech@ucw.cz>
    Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    d47255d3
amdgpu_device.c 148 KB