intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 4/8] drm/i915: fix the "ghost eDP" connector unwind path
Date: Wed, 12 Jun 2013 17:27:26 -0300	[thread overview]
Message-ID: <1371068850-3531-5-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <1371068850-3531-1-git-send-email-przanoni@gmail.com>

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

Because calling intel_dp_destroy inside intel_edp_init_connector is
just wrong. This is the initialization path, so we should properly
unwind all the initialization through the whole caller stack.

On the intel_dp_destroy function we do the following:
1 - Free edid if it exists
2 - Call intel_panel_fini in case it's eDP
3 - Call drm_sysfs_connector_remove
4 - Call drm_connector_cleanup
5 - Free the connector

And here is how we unwind each specific step:
1 - No need as we still didn't assign anything
2 - No need as we still didn't call intel_panel_init
3 - Call it in the same function that called drm_sysfs_connector_add
4 - Call it in the same function that called drm_connector_init
5 - Free it in the same function that allocated it

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 4 +++-
 drivers/gpu/drm/i915/intel_dp.c  | 9 ++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 0f835d1..aed363c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1356,8 +1356,10 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 	intel_encoder->cloneable = false;
 	intel_encoder->hot_plug = intel_ddi_hot_plug;
 
-	if (!intel_dp_init_connector(intel_dig_port, dp_connector))
+	if (!intel_dp_init_connector(intel_dig_port, dp_connector)) {
+		kfree(dp_connector);
 		return;
+	}
 
 	if (intel_encoder->type != INTEL_OUTPUT_EDP) {
 		hdmi_connector = kzalloc(sizeof(struct intel_connector),
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 46b3e3b..da7460c 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2987,7 +2987,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
 		/* if this fails, presume the device is a ghost */
 		DRM_INFO("failed to retrieve link info, disabling eDP\n");
 		intel_dp_encoder_destroy(&intel_dig_port->base.base);
-		intel_dp_destroy(connector);
 		return false;
 	}
 
@@ -3146,8 +3145,11 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
 
 	intel_dp_i2c_init(intel_dp, intel_connector, name);
 
-	if (!intel_edp_init_connector(intel_dp, intel_connector))
+	if (!intel_edp_init_connector(intel_dp, intel_connector)) {
+		drm_sysfs_connector_remove(connector);
+		drm_connector_cleanup(connector);
 		return false;
+	}
 
 	intel_dp_add_properties(intel_dp, connector);
 
@@ -3206,5 +3208,6 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
 	intel_encoder->cloneable = false;
 	intel_encoder->hot_plug = intel_dp_hot_plug;
 
-	intel_dp_init_connector(intel_dig_port, intel_connector);
+	if (!intel_dp_init_connector(intel_dig_port, intel_connector))
+		kfree(intel_connector);
 }
-- 
1.8.1.2

  parent reply	other threads:[~2013-06-12 20:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12 20:27 [PATCH 0/8] Don't let the ghost eDP haunt us Paulo Zanoni
2013-06-12 20:27 ` [PATCH 1/8] drm/i915: don't check encoder at DP connector destroy() Paulo Zanoni
2013-06-12 20:27 ` [PATCH 2/8] drm/i915: extract intel_edp_init_connector Paulo Zanoni
2013-06-12 20:27 ` [PATCH 3/8] drm/i915: propagate errors from intel_dp_init_connector Paulo Zanoni
2013-06-12 20:27 ` Paulo Zanoni [this message]
2013-06-12 20:27 ` [PATCH 5/8] drm/i915: fix the "ghost eDP" encoder unwind path Paulo Zanoni
2013-06-12 20:27 ` [PATCH 6/8] drm/i915: check the return value of intel_dp_i2c_init Paulo Zanoni
2013-06-12 20:27 ` [PATCH 7/8] drm/i915: invert the verbosity of intel_enable_fbc Paulo Zanoni
2013-06-12 20:27 ` [PATCH 8/8] drm/i915: rename intel_dp_destroy to intel_dp_connector_destroy Paulo Zanoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371068850-3531-5-git-send-email-przanoni@gmail.com \
    --to=przanoni@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).