Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3693661pxb; Mon, 24 Jan 2022 15:33:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzC4EwTeAOJ1mKfvq6X/lsmXDkweSicsXMXODVWZf2HMoUbGY6IMPSC1x3aO0N/+GENS9o4 X-Received: by 2002:a65:5887:: with SMTP id d7mr6725113pgu.503.1643067197475; Mon, 24 Jan 2022 15:33:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067197; cv=none; d=google.com; s=arc-20160816; b=VKVzLUGDqMWDhwFIw+S/hxrkGzG55A9e+PH6ZLpzCZLZnPTvmKtSc85gwgqioSSVdK +/gDK1Xire1SV1aT+iDNR1gDwFxb+/KRmyBh8Yv5thV8i8CYa1g9hn50Ar3yEqpqiv0V P9FEiOoKGQMznta/3qRBzI6aYpCOYbG8HtVr7LNDmfAryEirWLWn41+ARl+SIHNJttCO WN4IVqKFQXzDxXt/WDHlnr0VxtHdAB307q3rhuUXs2qoDzu5K+oAA6WqgorkHQGV28sw JkF6e+WxTMHGktgFoUT+2dTox/ntSrtKJcVk6quHK3hTVr6qd0WI2n+rSQ4RqAC+u+X2 DV8g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KpsBSISt/DrtFDRTuyWO9ZYRJ7F+Lei7iO6SmcOmUko=; b=d+Nsc1G2hNMVgut9nfBCrNdVtqSs3i8LG9ylfhjEaFfvVkjAEFnOZ+iU/ZyK8vyolg 1KRTtagTBXwpG129tI5UjpyzxawVdeyvlS+36yRz2AWkNX/Bt3aDlyFT71f//s1yQNhE Mj5nA//L2umtrf1S7ZVAyNhAP2aD7wr+o5/PDzjh6GjMqeKzMOzxEWDM0QnFbM6d2nxm XtK4ohC/smRDgRMkXlSFzByUL4sihlPXa/k/PHE1rudPsfRuLWFyN27DDEphbcH13K/1 M2MsNUw1qNvNUrUjGXEEzo2k15+8r+5YanrjEGTNTHtjmi1mSBBItxM9Fos4yy0uVJhi gTXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MzPs1qb3; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u187si803111pfc.16.2022.01.24.15.33.05; Mon, 24 Jan 2022 15:33:17 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=MzPs1qb3; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1849949AbiAXX1D (ORCPT + 99 others); Mon, 24 Jan 2022 18:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1835190AbiAXWfs (ORCPT ); Mon, 24 Jan 2022 17:35:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 766A8C07A94A; Mon, 24 Jan 2022 12:58:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 14FB160C60; Mon, 24 Jan 2022 20:58:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 003D2C340E5; Mon, 24 Jan 2022 20:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057920; bh=IyH1Lh56yH9JDasMVhjm5n150Kxj6K6Tx0L9VwNIBGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MzPs1qb3Pl03QKDqrSvcZ5M/vc4Y+RIuVLLwLEQAHyp5i+HjlcpVYDtho/VfarzhM wYrOQI+BPvflSpHlk95JMu1nsVmvuoz7rh0mEqBdBhSbm4WQZwYD3J4JCMtK5LPY7+ 9pcw6sPO/T7vFdG9FGdHdavt+3bw0KOCU7nikNJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Sam Ravnborg , Sasha Levin Subject: [PATCH 5.16 0089/1039] drm/panel: innolux-p079zca: Delete panel on attach() failure Date: Mon, 24 Jan 2022 19:31:18 +0100 Message-Id: <20220124184128.149662846@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Norris [ Upstream commit 32a267e9c057e1636e7afdd20599aa5741a73079 ] If we fail to attach (e.g., because 1 of 2 dual-DSI controllers aren't ready), we leave a dangling drm_panel reference to freed memory. Clean that up on failure. This problem exists since the driver's introduction, but is especially relevant after refactored for dual-DSI variants. Fixes: 14c8f2e9f8ea ("drm/panel: add Innolux P079ZCA panel driver") Fixes: 7ad4e4636c54 ("drm/panel: p079zca: Refactor panel driver to support multiple panels") Signed-off-by: Brian Norris Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20210923173336.2.I9023cf8811a3abf4964ed84eb681721d8bb489d6@changeid Signed-off-by: Sasha Levin --- drivers/gpu/drm/panel/panel-innolux-p079zca.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c index aea3162253914..f194b62e290ca 100644 --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c @@ -484,6 +484,7 @@ static void innolux_panel_del(struct innolux_panel *innolux) static int innolux_panel_probe(struct mipi_dsi_device *dsi) { const struct panel_desc *desc; + struct innolux_panel *innolux; int err; desc = of_device_get_match_data(&dsi->dev); @@ -495,7 +496,14 @@ static int innolux_panel_probe(struct mipi_dsi_device *dsi) if (err < 0) return err; - return mipi_dsi_attach(dsi); + err = mipi_dsi_attach(dsi); + if (err < 0) { + innolux = mipi_dsi_get_drvdata(dsi); + innolux_panel_del(innolux); + return err; + } + + return 0; } static int innolux_panel_remove(struct mipi_dsi_device *dsi) -- 2.34.1