Skip to content

Commit 3eadd88

Browse files
committed
drm/client: Fully protect modes[] with dev->mode_config.mutex
The modes[] array contains pointers to modes on the connectors' mode lists, which are protected by dev->mode_config.mutex. Thus we need to extend modes[] the same protection or by the time we use it the elements may already be pointing to freed/reused memory. Cc: stable@vger.kernel.org Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10583 Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240404203336.10454-2-ville.syrjala@linux.intel.com Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
1 parent 8ab58f6 commit 3eadd88

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/gpu/drm/drm_client_modeset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
777777
unsigned int total_modes_count = 0;
778778
struct drm_client_offset *offsets;
779779
unsigned int connector_count = 0;
780+
/* points to modes protected by mode_config.mutex */
780781
struct drm_display_mode **modes;
781782
struct drm_crtc **crtcs;
782783
int i, ret = 0;
@@ -845,7 +846,6 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
845846
drm_client_pick_crtcs(client, connectors, connector_count,
846847
crtcs, modes, 0, width, height);
847848
}
848-
mutex_unlock(&dev->mode_config.mutex);
849849

850850
drm_client_modeset_release(client);
851851

@@ -875,6 +875,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
875875
modeset->y = offset->y;
876876
}
877877
}
878+
mutex_unlock(&dev->mode_config.mutex);
878879

879880
mutex_unlock(&client->modeset_mutex);
880881
out:

0 commit comments

Comments
 (0)