Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1322241yba; Tue, 2 Apr 2019 06:51:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQOwy6U9/zd6B07XITOjDL+uoIhu+44ahe2EO8gYqQJo13v5zH3BcxUrY+KGfBh4QL1/UW X-Received: by 2002:a65:5a81:: with SMTP id c1mr65940799pgt.391.1554213092047; Tue, 02 Apr 2019 06:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554213092; cv=none; d=google.com; s=arc-20160816; b=hRPraa2IU8fyKkFu0dXC8uDWNwq1W2F8jKxkUPv6AnO6G2SMqt0xxuDNPMRegd71KP NnmPLQ/mgxpsovNTV21Ncg7c5Jk01OjMY9k6Abjh2418EOmcynQ9cHdRobVTjuKnlxyg pOlRe+WPQnyYPF4gnEcGJhOvWy6hnzhvW175FIaz9ESVr5pfAgY/5MrPs85rS1h9d2MS TvIM/XD8sHhSlNIYZtM8/GEKlbyE4HtL/dtsv4U+mxWOOrjO8HXn6u1BiugnBMC8XafZ v5v1dapDqtJfyLLqbpTRdBTD5YvW3F7w1+ItePBGVmmbp765bcp32YUp40CnT/9iZny8 pZ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nBDVsx6u6bC3GZYfu3AzkRFDepcZ+AZwpN5Tro0+gPw=; b=d/VyKZgFJ+LNpOha1RNrU32/+4yWp6ZN2PcwahY5GZiCECrCCc+MsAIXSgiTJsXcd1 JHgah/JxQbs3kFkI1jthx9/L/IL+pjH2jFSlncnlXUBNu+XNStFOAUly2jTo+fuK6mpU fqR54AM4l2L01NZflCqgLNqwmbF2Fd7sfwv/cOYJ76KefAcFEgx11I9cIBAeMVndfgUh H0KwSSDoqiH4Y5ig8Jeyv4m44HR1qT3m0qNaZgnxg/tPY5ZNzZsPhB7VuJV8AWKG4C33 fenbQYvevAAaeNWzvHf9Kl+KQ+cZ9alaJkYqgc9rNnOaS25loiYWeQf/BMiNeEghL59x jPoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d40si11593991pla.114.2019.04.02.06.51.16; Tue, 02 Apr 2019 06:51:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732240AbfDBNt3 (ORCPT + 99 others); Tue, 2 Apr 2019 09:49:29 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:40629 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731168AbfDBNt2 (ORCPT ); Tue, 2 Apr 2019 09:49:28 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJmn-0007VR-Js; Tue, 02 Apr 2019 15:49:09 +0200 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92-RC6) (envelope-from ) id 1hBJmm-0001EB-Ra; Tue, 02 Apr 2019 15:49:08 +0200 From: Michael Grzeschik 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 Message-Id: <20190402134904.588-4-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190402134904.588-1-m.grzeschik@pengutronix.de> References: <0687f68004b28ed3a364b06a9eb64e2e@agner.ch> <20190402134904.588-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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