Patch "drm/fb_helper: Fix references to dev->mode_config.num_connector" has been added to the 3.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
drm/fb_helper: Fix references to dev->mode_config.num_connector
to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
drm-fb_helper-fix-references-to-dev-mode_config.num_connector.patch
and it can be found in the queue-3.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
255f0e7c418ad95a4baeda017ae6182ba9b3c423Mon Sep 17 00:00:00 2001
From: Lyude <[email protected]>
Date: Thu, 12 May 2016 10:56:59 -0400
Subject: drm/fb_helper: Fix references to dev->mode_config.num_connector
From: Lyude <[email protected]>
commit 255f0e7c418ad95a4baeda017ae6182ba9b3c423 upstream.
During boot, MST hotplugs are generally expected (even if no physical hotplugging occurs) and result in DRM's connector topology changing. This means that using num_connector from the current mode configuration can lead to the number of connectors changing under us. This can lead to some nasty scenarios in fbcon:
- We allocate an array to the size of dev->mode_config.num_connectors.
- MST hotplug occurs, dev->mode_config.num_connectors gets incremented.
- We try to loop through each element in the array using the new value of dev->mode_config.num_connectors, and end up going out of bounds since dev->mode_config.num_connectors is now larger then the array we allocated.
fb_helper->connector_count however, will always remain consistent while we do a modeset in fb_helper.
Note: This is just polish for 4.7, Dave Airlie's drm_connector refcounting fixed these bugs for real. But it's good enough duct-tape for stable kernel backporting, since backporting the refcounting changes is way too invasive.
[danvet: Clarify why we need this. Also remove the now unused "dev" local variable to appease gcc.]
--- drivers/gpu/drm/drm_fb_helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +2 -3
@@ -1347,7 +1347,6 @@ static int drm_pick_crtcs(struct drm_fb_ int n, int width, int height) { int c, o; -struct drm_device *dev = fb_helper->dev;struct drm_connector *connector;struct drm_connector_helper_funcs *connector_funcs;struct drm_encoder *encoder;
@@ -1366,7 +1365,7 @@ static int drm_pick_crtcs(struct drm_fb_if (modes[n] ==NULL )return best_score; - crtcs =kzalloc (dev->mode_config.num_connector * + crtcs =kzalloc (fb_helper->connector_count *sizeof (struct drm_fb_helper_crtc *),GFP_KERNEL );if (!crtcs)return best_score;
@@ -1412,7 +1411,7 @@ static int drm_pick_crtcs(struct drm_fb_if (score > best_score) { best_score = score;memcpy (best_crtcs, crtcs, - dev->mode_config.num_connector * + fb_helper->connector_count *sizeof (struct drm_fb_helper_crtc *)); } }
Patches currently in stable-queue which might be from [email protected] are
queue-3.14/drm-fb_helper-fix-references-to-dev-mode_config.num_connector.patch