Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp879091pxk; Thu, 17 Sep 2020 20:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK+dxuKjK2OLi+tlurr5qbRP92I/P/oYsLxsO90mT2O7n4bvPrtPdd2QWMrndopaF1Ze6A X-Received: by 2002:a17:906:c411:: with SMTP id u17mr33170562ejz.319.1600398525318; Thu, 17 Sep 2020 20:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398525; cv=none; d=google.com; s=arc-20160816; b=zqwsTXkDoDT+frwxWbomW0VGQEAfd6FHxT8EjsHEwvNd7nEtdPML2MhvwtzBcy7bqq 58UTMJ2rFQAoebhftft4ZYDQym8wFydCzv/QX+bi65/tsfQCXOh3wSN6x5DsG1rpCJdR v44QV6+P59iqSh3r+ZaEKTFG1zF90/ms1ENBx5pP7nHAgpOY1LUwKgRBL3XsuVA3FUl6 sMxnol8BwYgq1fj5pVyTKoNMV6oSycPYZSOFHs1QOUDVyB49Sia3tlOPPjmbL45fJ/Sn YcNziIurwPpfKyXCycOnPmfAOKx772illVtW0HInETGudLL6NgZZb7PdQOIIM5oTUgxW JSnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pjZ+UZeWr4r9DxNLi2c6SgBaAbTSO991OwAzSSM/FSk=; b=dTtsziuKSDEgyQkCBaMh8g+JSPLLkI7dT5bnU0aQ/BMZM9ECeNWA+3g/9AgtpYaZ+s FggSEjiM2DwXxrhlA7duIARGdNB12y4gUGFqekWucJe2sAoXjLHLO968JLXxcoMU+q6A 61CQ4TOIJmOIbaxnnCLuY4W2SbylHrCtQ/B9svXxWk77qBZPOGbRA8JrlpYNPYFNBDhQ tS+SCQDnIf8kK2dvInAbO9F1QR04nd1yK8YKVCpU9L3eotrs5IHtiLvfO6rC2TKAXSaG b5F/WD0ZlDQZtCyQ9gNPuOq+ash44DgT5ZhkMQLY9N+PcwIZEZlcGfgyBIwqjjh1nuS2 609w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RY4fdy3g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si1054798edt.233.2020.09.17.20.08.22; Thu, 17 Sep 2020 20:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RY4fdy3g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730484AbgIRDGN (ORCPT + 99 others); Thu, 17 Sep 2020 23:06:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:51126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbgIRCEH (ORCPT ); Thu, 17 Sep 2020 22:04:07 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C44121734; Fri, 18 Sep 2020 02:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394647; bh=Hcyl6z3B1/m/mJGIPwQu7w5hswHWOPYrcDWuFQMM60k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RY4fdy3gLerpKO+sVX16hMNUXELWhutGcDpKiJnYmyhvgxirDjtzjM/GQIburxZW6 KoaMN1RtOqRbxCXATHUve6WTCg1IhvyJgaUgrQiRoo909ERzhkpjxOu8xKfFyE0/vr IZjfAZffs93F+oT4D1OKgOYPT0JFXTHZSecM0TXQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Laurent Pinchart , Hans Verkuil , Tomi Valkeinen , Sam Ravnborg , Sebastian Reichel , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 144/330] drm/omap: dss: Cleanup DSS ports on initialisation failure Date: Thu, 17 Sep 2020 21:58:04 -0400 Message-Id: <20200918020110.2063155-144-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart [ Upstream commit 2a0a3ae17d36fa86dcf7c8e8d7b7f056ebd6c064 ] When the DSS initialises its output DPI and SDI ports, failures don't clean up previous successfully initialised ports. This can lead to resource leak or memory corruption. Fix it. Reported-by: Hans Verkuil Signed-off-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Acked-by: Sam Ravnborg Tested-by: Sebastian Reichel Reviewed-by: Sebastian Reichel Signed-off-by: Tomi Valkeinen Link: https://patchwork.freedesktop.org/patch/msgid/20200226112514.12455-22-laurent.pinchart@ideasonboard.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/omapdrm/dss/dss.c | 43 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 4bdd63b571002..ac93dae2a9c84 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1151,46 +1151,38 @@ static const struct dss_features dra7xx_dss_feats = { .has_lcd_clk_src = true, }; -static int dss_init_ports(struct dss_device *dss) +static void __dss_uninit_ports(struct dss_device *dss, unsigned int num_ports) { struct platform_device *pdev = dss->pdev; struct device_node *parent = pdev->dev.of_node; struct device_node *port; unsigned int i; - int r; - for (i = 0; i < dss->feat->num_ports; i++) { + for (i = 0; i < num_ports; i++) { port = of_graph_get_port_by_id(parent, i); if (!port) continue; switch (dss->feat->ports[i]) { case OMAP_DISPLAY_TYPE_DPI: - r = dpi_init_port(dss, pdev, port, dss->feat->model); - if (r) - return r; + dpi_uninit_port(port); break; - case OMAP_DISPLAY_TYPE_SDI: - r = sdi_init_port(dss, pdev, port); - if (r) - return r; + sdi_uninit_port(port); break; - default: break; } } - - return 0; } -static void dss_uninit_ports(struct dss_device *dss) +static int dss_init_ports(struct dss_device *dss) { struct platform_device *pdev = dss->pdev; struct device_node *parent = pdev->dev.of_node; struct device_node *port; - int i; + unsigned int i; + int r; for (i = 0; i < dss->feat->num_ports; i++) { port = of_graph_get_port_by_id(parent, i); @@ -1199,15 +1191,32 @@ static void dss_uninit_ports(struct dss_device *dss) switch (dss->feat->ports[i]) { case OMAP_DISPLAY_TYPE_DPI: - dpi_uninit_port(port); + r = dpi_init_port(dss, pdev, port, dss->feat->model); + if (r) + goto error; break; + case OMAP_DISPLAY_TYPE_SDI: - sdi_uninit_port(port); + r = sdi_init_port(dss, pdev, port); + if (r) + goto error; break; + default: break; } } + + return 0; + +error: + __dss_uninit_ports(dss, i); + return r; +} + +static void dss_uninit_ports(struct dss_device *dss) +{ + __dss_uninit_ports(dss, dss->feat->num_ports); } static int dss_video_pll_probe(struct dss_device *dss) -- 2.25.1