mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: p.zabel@pengutronix.de, airlied@linux.ie, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux@armlinux.org.uk,
	dri-devel@lists.freedesktop.org, rafael@kernel.org,
	kernel@pengutronix.de
Subject: [PATCH 3/3] ipuv3-ldb: add remove action for devres data
Date: Tue,  2 Apr 2019 15:49:04 +0200	[thread overview]
Message-ID: <20190402134904.588-4-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20190402134904.588-1-m.grzeschik@pengutronix.de>

The destroy function in drm_mode_config_cleanup will remove the objects
in ipu-drm-core by calling its destroy functions if the bind function
fails. The drm_encoder is also part of the devres allocated ipu_ldb
object. The ipu_ldb object will already be cleaned up if the bind for
the crtc fails. This leads drm_encoder_cleanup try to clean already freed
memory.

We fix this issue by adding the devres action ipu_ldb_remove_head which
will remove its head from the objects in ipu-drm-core which then never
calls its destroy function anymore.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/gpu/drm/imx/imx-ldb.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index a11f8758da70e..0a224036cc68d 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -581,6 +581,21 @@ static int imx_ldb_panel_ddc(struct device *dev,
 	return 0;
 }
 
+static void ipu_ldb_remove_head(void *data)
+{
+	struct imx_ldb *imx_ldb = data;
+	struct imx_ldb_channel *imx_ldb_ch;
+	struct drm_encoder *encoder;
+
+	imx_ldb_ch = &imx_ldb->channel[0];
+	encoder = &imx_ldb_ch->encoder;
+	list_del_init(&encoder->head);
+
+	imx_ldb_ch = &imx_ldb->channel[1];
+	encoder = &imx_ldb_ch->encoder;
+	list_del_init(&encoder->head);
+}
+
 static void ipu_ldb_init_encoder_head(struct imx_ldb *imx_ldb)
 {
 	struct imx_ldb_channel *imx_ldb_ch;
@@ -613,6 +628,10 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
 
 	ipu_ldb_init_encoder_head(imx_ldb);
 
+	ret = devm_add_action(dev, ipu_ldb_remove_head, imx_ldb);
+	if (ret)
+		return ret;
+
 	imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr");
 	if (IS_ERR(imx_ldb->regmap)) {
 		dev_err(dev, "failed to get parent regmap\n");
-- 
2.20.1


      parent reply	other threads:[~2019-04-02 13:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0687f68004b28ed3a364b06a9eb64e2e@agner.ch>
2019-04-02 13:49 ` [PATCH 0/3] Fix for drm_mode_config_cleanup issue Michael Grzeschik
2019-04-02 13:49   ` [PATCH 1/3] ipuv3-crtc: add remove action for devres data Michael Grzeschik
2019-04-02 15:49     ` Philipp Zabel
2019-04-03  7:22       ` Daniel Vetter
2019-04-02 13:49   ` [PATCH 2/3] ipuv3-ldb: add init list head on bind Michael Grzeschik
2019-04-02 13:49   ` Michael Grzeschik [this message]

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=20190402134904.588-4-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=p.zabel@pengutronix.de \
    --cc=rafael@kernel.org \
    /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

all inboxes | Powered by JetHome®