drm/client: Fully protect modes[] with dev->mode_config.mutex
authorjsg <jsg@openbsd.org>
Thu, 18 Apr 2024 00:58:03 +0000 (00:58 +0000)
committerjsg <jsg@openbsd.org>
Thu, 18 Apr 2024 00:58:03 +0000 (00:58 +0000)
From Ville Syrjala
04e018bd913d3d3336ab7d21c2ad31a9175fe984 in linux-6.6.y/6.6.28
3eadd887dbac1df8f25f701e5d404d1b90fd0fea in mainline linux

sys/dev/pci/drm/drm_client_modeset.c

index 8d160df..21b9c6b 100644 (file)
@@ -777,6 +777,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
        unsigned int total_modes_count = 0;
        struct drm_client_offset *offsets;
        unsigned int connector_count = 0;
+       /* points to modes protected by mode_config.mutex */
        struct drm_display_mode **modes;
        struct drm_crtc **crtcs;
        int i, ret = 0;
@@ -855,7 +856,6 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
                drm_client_pick_crtcs(client, connectors, connector_count,
                                      crtcs, modes, 0, width, height);
        }
-       mutex_unlock(&dev->mode_config.mutex);
 
        drm_client_modeset_release(client);
 
@@ -885,6 +885,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
                        modeset->y = offset->y;
                }
        }
+       mutex_unlock(&dev->mode_config.mutex);
 
        mutex_unlock(&client->modeset_mutex);
 out: