Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0ddfbd3 authored by Jani Nikula's avatar Jani Nikula Committed by Daniel Vetter
Browse files

drm/i915/sdvo: clean up connectors on intel_sdvo_init() failures

Any failures in intel_sdvo_init() after the intel_sdvo_setup_output() call
left behind ghost connectors, attached (with a dangling pointer) to the
sdvo that has been cleaned up and freed. Properly destroy any connectors
attached to the encoder.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=46381


CC: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Cc: stable@vger.kernel.org
Tested-by: default avatar <bjo@nord-west.org>
[danvet: added a comment to explain why we need to clean up connectors
even when sdvo_output_setup fails.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 4a8dece2
Loading
Loading
Loading
Loading
+19 −3
Original line number Original line Diff line number Diff line
@@ -2382,6 +2382,18 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags)
	return true;
	return true;
}
}


static void intel_sdvo_output_cleanup(struct intel_sdvo *intel_sdvo)
{
	struct drm_device *dev = intel_sdvo->base.base.dev;
	struct drm_connector *connector, *tmp;

	list_for_each_entry_safe(connector, tmp,
				 &dev->mode_config.connector_list, head) {
		if (intel_attached_encoder(connector) == &intel_sdvo->base)
			intel_sdvo_destroy(connector);
	}
}

static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
					  struct intel_sdvo_connector *intel_sdvo_connector,
					  struct intel_sdvo_connector *intel_sdvo_connector,
					  int type)
					  int type)
@@ -2705,7 +2717,8 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
				    intel_sdvo->caps.output_flags) != true) {
				    intel_sdvo->caps.output_flags) != true) {
		DRM_DEBUG_KMS("SDVO output failed to setup on %s\n",
		DRM_DEBUG_KMS("SDVO output failed to setup on %s\n",
			      SDVO_NAME(intel_sdvo));
			      SDVO_NAME(intel_sdvo));
		goto err;
		/* Output_setup can leave behind connectors! */
		goto err_output;
	}
	}


	/* Only enable the hotplug irq if we need it, to work around noisy
	/* Only enable the hotplug irq if we need it, to work around noisy
@@ -2718,12 +2731,12 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)


	/* Set the input timing to the screen. Assume always input 0. */
	/* Set the input timing to the screen. Assume always input 0. */
	if (!intel_sdvo_set_target_input(intel_sdvo))
	if (!intel_sdvo_set_target_input(intel_sdvo))
		goto err;
		goto err_output;


	if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo,
	if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo,
						    &intel_sdvo->pixel_clock_min,
						    &intel_sdvo->pixel_clock_min,
						    &intel_sdvo->pixel_clock_max))
						    &intel_sdvo->pixel_clock_max))
		goto err;
		goto err_output;


	DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, "
	DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, "
			"clock range %dMHz - %dMHz, "
			"clock range %dMHz - %dMHz, "
@@ -2743,6 +2756,9 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
			(SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
			(SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
	return true;
	return true;


err_output:
	intel_sdvo_output_cleanup(intel_sdvo);

err:
err:
	drm_encoder_cleanup(&intel_encoder->base);
	drm_encoder_cleanup(&intel_encoder->base);
	i2c_del_adapter(&intel_sdvo->ddc);
	i2c_del_adapter(&intel_sdvo->ddc);