Skip to content

Commit 1dfd286

Browse files
gnifAMDalexdeucher
authored andcommitted
drm/amd/display: remove oem i2c adapter on finish
Fixes a bug where unbinding of the GPU would leave the oem i2c adapter registered resulting in a null pointer dereference when applications try to access the invalid device. Fixes: 3d5470c ("drm/amd/display/dm: add support for OEM i2c bus") Cc: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Geoffrey McRae <geoffrey.mcrae@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 89923fb) Cc: stable@vger.kernel.org
1 parent 60f71f0 commit 1dfd286

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,17 @@ static int dm_oem_i2c_hw_init(struct amdgpu_device *adev)
29132913
return 0;
29142914
}
29152915

2916+
static void dm_oem_i2c_hw_fini(struct amdgpu_device *adev)
2917+
{
2918+
struct amdgpu_display_manager *dm = &adev->dm;
2919+
2920+
if (dm->oem_i2c) {
2921+
i2c_del_adapter(&dm->oem_i2c->base);
2922+
kfree(dm->oem_i2c);
2923+
dm->oem_i2c = NULL;
2924+
}
2925+
}
2926+
29162927
/**
29172928
* dm_hw_init() - Initialize DC device
29182929
* @ip_block: Pointer to the amdgpu_ip_block for this hw instance.
@@ -2963,7 +2974,7 @@ static int dm_hw_fini(struct amdgpu_ip_block *ip_block)
29632974
{
29642975
struct amdgpu_device *adev = ip_block->adev;
29652976

2966-
kfree(adev->dm.oem_i2c);
2977+
dm_oem_i2c_hw_fini(adev);
29672978

29682979
amdgpu_dm_hpd_fini(adev);
29692980

0 commit comments

Comments
 (0)