Skip to content

Commit 89923fb

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>
1 parent 276e8be commit 89923fb

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
@@ -2957,6 +2957,17 @@ static int dm_oem_i2c_hw_init(struct amdgpu_device *adev)
29572957
return 0;
29582958
}
29592959

2960+
static void dm_oem_i2c_hw_fini(struct amdgpu_device *adev)
2961+
{
2962+
struct amdgpu_display_manager *dm = &adev->dm;
2963+
2964+
if (dm->oem_i2c) {
2965+
i2c_del_adapter(&dm->oem_i2c->base);
2966+
kfree(dm->oem_i2c);
2967+
dm->oem_i2c = NULL;
2968+
}
2969+
}
2970+
29602971
/**
29612972
* dm_hw_init() - Initialize DC device
29622973
* @ip_block: Pointer to the amdgpu_ip_block for this hw instance.
@@ -3007,7 +3018,7 @@ static int dm_hw_fini(struct amdgpu_ip_block *ip_block)
30073018
{
30083019
struct amdgpu_device *adev = ip_block->adev;
30093020

3010-
kfree(adev->dm.oem_i2c);
3021+
dm_oem_i2c_hw_fini(adev);
30113022

30123023
amdgpu_dm_hpd_fini(adev);
30133024

0 commit comments

Comments
 (0)