summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_connector.h
diff options
context:
space:
mode:
authorLyude Paul2018-07-13 19:06:32 +0200
committerBen Skeggs2018-07-16 09:59:59 +0200
commit22b76bbe089cd901f5260ecb9a3dc41f9edb97a0 (patch)
tree46cc6c81edf814a1cff1f5c06a328e9db822d4b3 /drivers/gpu/drm/nouveau/nouveau_connector.h
parentdrm/nouveau/gem: off by one bugs in nouveau_gem_pushbuf_reloc_apply() (diff)
downloadkernel-qcow2-linux-22b76bbe089cd901f5260ecb9a3dc41f9edb97a0.tar.gz
kernel-qcow2-linux-22b76bbe089cd901f5260ecb9a3dc41f9edb97a0.tar.xz
kernel-qcow2-linux-22b76bbe089cd901f5260ecb9a3dc41f9edb97a0.zip
drm/nouveau: Use drm_connector_list_iter_* for iterating connectors
Every codepath in nouveau that loops through the connector list currently does so using the old method, which is prone to race conditions from MST connectors being created and destroyed. This has been causing a multitude of problems, including memory corruption from trying to access connectors that have already been freed! Signed-off-by: Lyude Paul <lyude@redhat.com> Cc: stable@vger.kernel.org Cc: Karol Herbst <karolherbst@gmail.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_connector.h')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h
index a4d1a059bd3d..a8cbb4b56fc7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.h
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.h
@@ -65,14 +65,20 @@ nouveau_crtc_connector_get(struct nouveau_crtc *nv_crtc)
{
struct drm_device *dev = nv_crtc->base.dev;
struct drm_connector *connector;
+ struct drm_connector_list_iter conn_iter;
+ struct nouveau_connector *nv_connector = NULL;
struct drm_crtc *crtc = to_drm_crtc(nv_crtc);
- list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
- if (connector->encoder && connector->encoder->crtc == crtc)
- return nouveau_connector(connector);
+ drm_connector_list_iter_begin(dev, &conn_iter);
+ drm_for_each_connector_iter(connector, &conn_iter) {
+ if (connector->encoder && connector->encoder->crtc == crtc) {
+ nv_connector = nouveau_connector(connector);
+ break;
+ }
}
+ drm_connector_list_iter_end(&conn_iter);
- return NULL;
+ return nv_connector;
}
struct drm_connector *