From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A07C35C193 for ; Fri, 3 Apr 2026 06:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775199043; cv=none; b=sZLlIY6OtU+8qbeG0+5weHdlZTvy+S4tLBxbj3jtJTjrRBWiNF43ElG0+uAN4rCt3JYHmdBeq8NtqfruxmC8H35NdbXl6PruO6hPrJhvDg/Zu4yQnnPsaaxz07nHLZ4+yajS8dilY9AQtLep+pbsetXsoNlpQr4j87Vtq52bpXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775199043; c=relaxed/simple; bh=F70E1hVCPciZL1hdpc7vVRaOLQEFQIvSHIj2THkHqQA=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:To:From: References:In-Reply-To; b=DrCwIARJWUHD9Ge2hLM3w2UdvBKrmdlL56fDuOUBVv7fbAt4dQ1vntwiqDj7IwJn1q649JQg8MYe2x6UoB/rjJJMdzqEIg+GXOAMlhx4v/UtiKS5XgjR8SkSvMeDwsK9WaCklZmwwsf6Cxx5ldiJOny3EEX6PJ0m3VdDefndfZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=J6vAZSbD; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="J6vAZSbD" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 653AD1A3114; Fri, 3 Apr 2026 06:50:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 28ACB603C1; Fri, 3 Apr 2026 06:50:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A7D55104511F1; Fri, 3 Apr 2026 08:50:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775199036; h=from:subject:date:message-id:to:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=LH3skQP6GTlzPiY1OJgOP3dEsK1r+TyeIvszKOXNfqQ=; b=J6vAZSbDIxnWOQi8efV17BuZOduHbXLOM/cyaip2+/BOx8azwkfKmwrh3WC5SW/nhZI27+ muilFROtYLXnBnTfWz2JpWplHIWFMkBr3ZsuWBINW4kOw0frioa3KVKokUoq1BgiEWFfBb 8Gx5td4aN+avLmfwjAquP83DmT2ktJbh4VSLunyzxuHimZrm8USMFMKZXBYosD4JPOxNyd eBK1PAdTG2aZicfbHH7MY2FQPipDjk9ayLJ+5lnVn3KcmMkYm/hV4No7fyPwxX2U+CI7Ce Kd9LXXb2i4ZALP2yNmMe9GZB1KKTPvw0fnwnmq3W0POcYxXJhMX/jG+Atk/9Ig== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 03 Apr 2026 08:50:29 +0200 Message-Id: Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Fix bridge leak when host attach fails To: "Osama Abdelkader" , "Andrzej Hajda" , "Neil Armstrong" , "Robert Foss" , "Laurent Pinchart" , "Jonas Karlman" , "Jernej Skrabec" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , =?utf-8?q?Andr=C3=A9_Almeida?= , "Manikandan Muralidharan" , "Kees Cook" , "Heiko Stuebner" , "Andy Yan" , , From: "Luca Ceresoli" X-Mailer: aerc 0.20.1 References: <20260402210054.42074-1-osama.abdelkader@gmail.com> In-Reply-To: <20260402210054.42074-1-osama.abdelkader@gmail.com> X-Last-TLS-Session-Version: TLSv1.3 Hello Osama, On Thu Apr 2, 2026 at 11:00 PM CEST, Osama Abdelkader wrote: > dw_mipi_dsi_host_attach() and dw_mipi_dsi2_host_attach() call > drm_bridge_add() before pdata->host_ops->attach(). If attach fails, > the bridge stayed registered without drm_bridge_remove(), leaking the > bridge reference and leaving the device on the global bridge list. > > On failure, undo in the same order as host_detach(): for dw-mipi-dsi, > drm_of_panel_bridge_remove() then drm_bridge_remove(); for dw-mipi-dsi2, > drm_bridge_remove() then drm_of_panel_bridge_remove(). > > Fixes: 90910a651123 ("drm/bridge/synopsys: dsi: add ability to have glue-= specific attach and detach") > Fixes: 0d6d86253fef ("drm/bridge/synopsys: Add MIPI DSI2 host controller = bridge") > Signed-off-by: Osama Abdelkader > --- > drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 7 ++++++- > drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi2.c | 7 ++++++- > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/= drm/bridge/synopsys/dw-mipi-dsi.c > index ca4dea226f4b..ffa169c2de73 100644 > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c > @@ -345,10 +345,15 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_= host *host, > if (pdata->host_ops && pdata->host_ops->attach) { > ret =3D pdata->host_ops->attach(pdata->priv_data, device); > if (ret < 0) > - return ret; > + goto err_remove_bridge; > } > > return 0; > + > +err_remove_bridge: > + drm_of_panel_bridge_remove(host->dev->of_node, 1, 0); It was added by a devm_action, you shouldn't remove it here. Besides, devm_drm_of_get_bridge() might return A) a panel_bridge or B) a pointer to another, pre-existing bridge (and the called can't know which one got returned). drm_of_panel_bridge_remove() unconditionally removes a panel_bridge so it's wrong in case B. Which means the drm_of_panel_bridge_remove() in _host_detach is probably wrong and you should look at it. > + drm_bridge_remove(&dsi->bridge); This is correct, even though using devm_drm_bridge_add() instead of drm_bridge_add() above is probably the simplest solution. Same for the other driver in this patch. Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com