drm/amdgpu: warn if dp aux is still attached on free
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 2 Oct 2016 21:06:46 +0000 (00:06 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Oct 2016 16:39:03 +0000 (12:39 -0400)
If this happens (and it recently did), we free a structure while part of
it is still in use, which results in non-obvious crashes. The way it's
detached is not trivial (DRM core has to call the connector .destroy
callback and things must be torn down in the right order), so better
detect it and warn early.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c

index decbba5ad438cde053c42fa1f5ca1d4125fdecd3..49880983b0a2b7f4c7b50ea336967027ef8c5cb3 100644 (file)
@@ -769,8 +769,10 @@ static void amdgpu_connector_destroy(struct drm_connector *connector)
 {
        struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector);
 
-       if (amdgpu_connector->ddc_bus->has_aux)
+       if (amdgpu_connector->ddc_bus->has_aux) {
                drm_dp_aux_unregister(&amdgpu_connector->ddc_bus->aux);
+               amdgpu_connector->ddc_bus->has_aux = false;
+       }
        amdgpu_connector_free_edid(connector);
        kfree(amdgpu_connector->con_priv);
        drm_connector_unregister(connector);
index 34bab616588c06288fd1f13a8ead2b8357714eb6..91d367399956e55cae54c44b2b105cd7d07e5ea8 100644 (file)
@@ -220,6 +220,7 @@ void amdgpu_i2c_destroy(struct amdgpu_i2c_chan *i2c)
 {
        if (!i2c)
                return;
+       WARN_ON(i2c->has_aux);
        i2c_del_adapter(&i2c->adapter);
        kfree(i2c);
 }