Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4584381pxj; Wed, 12 May 2021 08:41:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFQ9dMjtRgON5fmCxZNMtqOXiYdG+ifIT0Oy1Eb6KBYgvgJyK5g5pWGaps3KRJ1hNNi7g4 X-Received: by 2002:a17:906:3042:: with SMTP id d2mr38774701ejd.234.1620834081442; Wed, 12 May 2021 08:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834081; cv=none; d=google.com; s=arc-20160816; b=hdm0uR7S2EnQS5yvMcnGdVal2916oAccFeArw06zJcBotP/JRrDR8T/09yUayq2y2+ mcdtf1JyRFYOK/uun54oDmz3bHxPfuPjHRdVDAO4niD9D0/SdtZg/EUVbEsrVkGarS1+ FXC3bSOzEjLi70JaRacdfwAC42heGQtE3nWMZ1hvWbzqXiz+NVHP3Y4yBFGfDvwuVrBA A7Q2zsbSSfEQiXRGxmtcbEiDwW52I+t64+oGf50yUunIsmXDnoyxmy3G9lLxrMSeb6zx 1JQ050qErohMhtD5vuXjcIwmW8OuPEGvRwrXbh7RSRO9b8Y9yz4FJ/LkYsCNK/mv4W7j AXIQ== 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=jRo6OBRsyZVYHuG/8XcC5YdwUR18yePYL4wB9GVNlbI=; b=xVh58vpSrKiVqwJUa0hOLQyS882pMiNd/09qjXH+sVoI+dXBn+x02Vtw3d3CV5/7DV 7zC6pj3jykj4KHF07UpGfuNXALyq1W2rdIOOE9hz6yFp0j/qlI1BY2uv8MEwqifzz+jT Ve+2HdVwOdsASvYDE6n0VVUD5Q/NHk+hgob9iKWDikTVJvs5ap0cpUpadSzwngENibnG uS3PvR3vWcyTBeDRoJyWyUhN091O0i1ek+80lU4m6S+9ufu8OBJtfKvBy7isqCqgD1Yt +HiL7BiwkkTpD2dglbupDvBPlfZMGykvek9Je/1+uNj8n2f/bGKj04TDtO+3j4lVyBNB 3DbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x7WUX7VJ; 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 g18si303868ejf.416.2021.05.12.08.40.57; Wed, 12 May 2021 08:41:21 -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=@linuxfoundation.org header.s=korg header.b=x7WUX7VJ; 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 S234411AbhELPji (ORCPT + 99 others); Wed, 12 May 2021 11:39:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbhELPRF (ORCPT ); Wed, 12 May 2021 11:17:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B49AE61108; Wed, 12 May 2021 15:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832028; bh=LQXZaWxdFrbx4iUlhxsh9hQfXSBcjHWTSy6hmOmnKfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x7WUX7VJ3laNjEwzYitysGThTxfEL4XxKTO/bIoGOA+ZouhxIVHKmZFjNprIftbLl pT8RjoX25oRSe1Euufjdw3Nwk4QE6WrEhToYBLgez/lNLOVgeTkW4kGSGFPfsnEWAa WBAxsyzChn4wyp0YPTkt1RLmIJqYplWcItOO5qX8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Paul Cercueil , Laurent Pinchart Subject: [PATCH 5.10 067/530] drm: bridge/panel: Cleanup connector on bridge detach Date: Wed, 12 May 2021 16:42:57 +0200 Message-Id: <20210512144821.958425866@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Paul Cercueil commit 4d906839d321c2efbf3fed4bc31ffd9ff55b75c0 upstream. If we don't call drm_connector_cleanup() manually in panel_bridge_detach(), the connector will be cleaned up with the other DRM objects in the call to drm_mode_config_cleanup(). However, since our drm_connector is devm-allocated, by the time drm_mode_config_cleanup() will be called, our connector will be long gone. Therefore, the connector must be cleaned up when the bridge is detached to avoid use-after-free conditions. v2: Cleanup connector only if it was created v3: Add FIXME v4: (Use connector->dev) directly in if() block Fixes: 13dfc0540a57 ("drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge.") Cc: # 4.12+ Cc: Andrzej Hajda Cc: Neil Armstrong Cc: Laurent Pinchart Cc: Jonas Karlman Cc: Jernej Skrabec Signed-off-by: Paul Cercueil Reviewed-by: Laurent Pinchart Link: https://patchwork.freedesktop.org/patch/msgid/20210327115742.18986-2-paul@crapouillou.net Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/bridge/panel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -87,6 +87,18 @@ static int panel_bridge_attach(struct dr static void panel_bridge_detach(struct drm_bridge *bridge) { + struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); + struct drm_connector *connector = &panel_bridge->connector; + + /* + * Cleanup the connector if we know it was initialized. + * + * FIXME: This wouldn't be needed if the panel_bridge structure was + * allocated with drmm_kzalloc(). This might be tricky since the + * drm_device pointer can only be retrieved when the bridge is attached. + */ + if (connector->dev) + drm_connector_cleanup(connector); } static void panel_bridge_pre_enable(struct drm_bridge *bridge)