[PATCH 3/6] drm/atomic: Don't overrun the connector array when hotplugging

Thierry Reding thierry.reding at gmail.com
Thu Nov 20 00:53:34 PST 2014


On Wed, Nov 19, 2014 at 06:38:08PM +0100, Daniel Vetter wrote:
[...]
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
[...]
> @@ -304,6 +306,21 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
>  
>  	index = drm_connector_index(connector);
>  
> +	/*
> +	 * Construction of atomic state updates can race with a connector
> +	 * hot-add which might overflow. In this case flip the table and just
> +	 * restart the entire ioctl - no one is fast enough to livelock a cpu
> +	 * with physical hotplug events anyway.
> +	 *
> +	 * Note that we only grab the indexes once we have the right lock to
> +	 * prevent hotplug/unplugging of connectors. So removal is no problem,
> +	 * at most the array is a bit too large.
> +	 */
> +	if (index >= state->num_connector) {
> +		DRM_DEBUG_KMS("Hot-added connector would overflow state array, restarting\n");
> +		return -EAGAIN;

This function returns a pointer, so this needs to be ERR_PTR(-EAGAIN).

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20141120/89b61ef0/attachment-0001.sig>


More information about the dri-devel mailing list