Message ID | 20230918150043.403250-1-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3057052vqi; Mon, 18 Sep 2023 18:05:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhJCLTh2D6QDfYENhyO8eZPBjOqXfmQhCttZJeTKDmkAeRTUk8de3fbVUXPRXE/QwuMwWJ X-Received: by 2002:a05:6a21:191:b0:14b:8b82:867f with SMTP id le17-20020a056a21019100b0014b8b82867fmr12976024pzb.50.1695085526483; Mon, 18 Sep 2023 18:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695085526; cv=none; d=google.com; s=arc-20160816; b=dr6AmZDc5NQKuXBzwELtLOjJCyYYIvUeGGRsXIcGUaX6kphfEeRVHOTifRhUd5JOc8 pELPXcobBwYL7tJle/kQhxf1TyrbMCQXepZb8yrVMv9nZ0b1h59k1xraOO2Uvs6J2pA4 QmT1N+CQ60NWl2jVG/ETYSuThI0l8jN2gfPtly+4LgN30tcykhaoSZKMBgnDk8Hx8FG+ eFDHAaKPp5id9lo5A+xP2iKHcnIb0XY426y7fdpZ96vGZKqnAUC51PyYOdekE9/8mtGy DnUkQBUInGasXNQExHtHyzNbI6YGBdjV4dfeIBuYrl9u/HZEbUMTMGswNV6VTr5A2+as LjXQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=P6s6hz1PqdiRetF3iwkG4Kv2uRHfBTSs5xCQWxsNZA8=; fh=l/zbhNQBbrfL3t9omnT691ovxrfEGzSTAk1OAVwp8vQ=; b=QCWGCsQXJ0PZwetOgmPvssGdj6Fg0Ge7Bbtv1AgqW2vJ3AGX29k0J1puBRBCl2AQBC 2WOCls2heA2azkNPS0/TZl0wgY+nnx7fmuInSyQ2ABQi0AiwmxA/6eDokvvsXaXqrst0 hfMfRE9NEHL9I6uvLBaaaNUH9rCzOzccQz2By4ijbgBnt0qku6lBfxvrpWIp4y8MJTLB 9waA9KOuOKXQ7CMlFGZOrd6sRsaES15ssX1FwoaqHKncnNKUShiTYcj5MuRTY5ULMqzi 5vwOKAF58ZGzuEj/5hsZMEvJ+kdG97Xy3cQlezWdqWSJY3mbqUU5Arbsy+/alBkcy3/Y khFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=END5yvqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w67-20020a636246000000b00577f9fa06e3si8695365pgb.706.2023.09.18.18.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 18:05:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=END5yvqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A86E68069D81; Mon, 18 Sep 2023 08:22:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjIRPWA (ORCPT <rfc822;kernel.ruili@gmail.com> + 27 others); Mon, 18 Sep 2023 11:22:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238837AbjIRPV7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 11:21:59 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0215E1991 for <linux-kernel@vger.kernel.org>; Mon, 18 Sep 2023 08:18:14 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id BF2C466072FB; Mon, 18 Sep 2023 16:01:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695049263; bh=4sbRG2aeCSqvnQfdgkb5xEWF2nVPvL6FiYhQyfisGCs=; h=From:To:Cc:Subject:Date:From; b=END5yvqWkPZ6TqXEEb3QXDyd6O9kk91YYcp4YfsHXOlfLL2esJhHnj4mo2svnZAKh wuR4OX6AGy7TOK3B+yAQ0vS13HNbM7lzqPC1U2fjYOFy+VrUa+ZQvJOx1LFPuHXbjc STDCAValnQVetcP6Ak8ZN6xop3bSG9fiUqhFX7rOReGAW40nGEIwU1AOPZMZLy1dCF vXZPbGbAo5CvaD4xQL3hFQD0gGHHV0jsbej1Lv1OgxbTkm6Lpngo7qi1A607Coc1B3 Ps9gTBi/PCQBarc4wFN8GHr2VyxbqkJ6fKHlRSSeIVAqvEehbHSlYXff8MJUcxUs0F zy11qj6g+LheA== From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: andrzej.hajda@intel.com Cc: neil.armstrong@linaro.org, rfoss@kernel.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@gmail.com, daniel@ffwll.ch, ulf.hansson@linaro.org, victor.liu@nxp.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, ehristev@collabora.com, wenst@chromium.org, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Subject: [PATCH] drm/bridge: panel: Fix device link for DRM_BRIDGE_ATTACH_NO_CONNECTOR Date: Mon, 18 Sep 2023 17:00:43 +0200 Message-ID: <20230918150043.403250-1-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:22:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777426000600133782 X-GMAIL-MSGID: 1777426000600133782 |
Series |
drm/bridge: panel: Fix device link for DRM_BRIDGE_ATTACH_NO_CONNECTOR
|
|
Commit Message
AngeloGioacchino Del Regno
Sept. 18, 2023, 3 p.m. UTC
When external bridges are attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR,
the panel bridge may also get the same flag, but in the .attach()
callback for the panel bridge a device link is added only when this
flag is not present; To make things worse, the .detach() callback
tries to delete the device link unconditionally and without checking
if it was created in the first place, crashing the kernel with a NULL
pointer kernel panic upon calling panel_bridge_detach().
Fix that by moving the device_link_add() call before checking if the
DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is present.
Fixes: 199cf07ebd2b ("drm/bridge: panel: Add a device link between drm device and panel device")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/gpu/drm/bridge/panel.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
Comments
Hi Angelo, Thank you for the patch. On Monday, September 18, 2023 11:01 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: > When external bridges are attached with > DRM_BRIDGE_ATTACH_NO_CONNECTOR, > the panel bridge may also get the same flag, but in the .attach() > callback for the panel bridge a device link is added only when this > flag is not present; To make things worse, the .detach() callback > tries to delete the device link unconditionally and without checking > if it was created in the first place, crashing the kernel with a NULL > pointer kernel panic upon calling panel_bridge_detach(). > > Fix that by moving the device_link_add() call before checking if the > DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is present. > > Fixes: 199cf07ebd2b ("drm/bridge: panel: Add a device link between drm > device and panel device") > Signed-off-by: AngeloGioacchino Del Regno > <angelogioacchino.delregno@collabora.com> > --- > drivers/gpu/drm/bridge/panel.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/panel.c > b/drivers/gpu/drm/bridge/panel.c > index e00d2e94c751..8c507dfd589e 100644 > --- a/drivers/gpu/drm/bridge/panel.c > +++ b/drivers/gpu/drm/bridge/panel.c > @@ -67,14 +67,6 @@ static int panel_bridge_attach(struct drm_bridge > *bridge, > struct drm_device *drm_dev = bridge->dev; > int ret; > > - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) > - return 0; > - > - if (!bridge->encoder) { > - DRM_ERROR("Missing encoder\n"); > - return -ENODEV; > - } > - > panel_bridge->link = device_link_add(drm_dev->dev, panel->dev, > DL_FLAG_STATELESS); > if (!panel_bridge->link) { > @@ -83,6 +75,14 @@ static int panel_bridge_attach(struct drm_bridge > *bridge, > return -EINVAL; > } > > + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) > + return 0; > + > + if (!bridge->encoder) { > + DRM_ERROR("Missing encoder\n"); Shouldn't the device link be deleted in case of error? Regards, Liu Ying > + return -ENODEV; > + } > + > drm_connector_helper_add(connector, > &panel_bridge_connector_helper_funcs); > > -- > 2.42.0
Il 19/09/23 03:45, Ying Liu ha scritto: > Hi Angelo, > > Thank you for the patch. > > On Monday, September 18, 2023 11:01 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: >> When external bridges are attached with >> DRM_BRIDGE_ATTACH_NO_CONNECTOR, >> the panel bridge may also get the same flag, but in the .attach() >> callback for the panel bridge a device link is added only when this >> flag is not present; To make things worse, the .detach() callback >> tries to delete the device link unconditionally and without checking >> if it was created in the first place, crashing the kernel with a NULL >> pointer kernel panic upon calling panel_bridge_detach(). >> >> Fix that by moving the device_link_add() call before checking if the >> DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is present. >> >> Fixes: 199cf07ebd2b ("drm/bridge: panel: Add a device link between drm >> device and panel device") >> Signed-off-by: AngeloGioacchino Del Regno >> <angelogioacchino.delregno@collabora.com> >> --- >> drivers/gpu/drm/bridge/panel.c | 16 ++++++++-------- >> 1 file changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/gpu/drm/bridge/panel.c >> b/drivers/gpu/drm/bridge/panel.c >> index e00d2e94c751..8c507dfd589e 100644 >> --- a/drivers/gpu/drm/bridge/panel.c >> +++ b/drivers/gpu/drm/bridge/panel.c >> @@ -67,14 +67,6 @@ static int panel_bridge_attach(struct drm_bridge >> *bridge, >> struct drm_device *drm_dev = bridge->dev; >> int ret; >> >> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) >> - return 0; >> - >> - if (!bridge->encoder) { >> - DRM_ERROR("Missing encoder\n"); >> - return -ENODEV; >> - } >> - >> panel_bridge->link = device_link_add(drm_dev->dev, panel->dev, >> DL_FLAG_STATELESS); >> if (!panel_bridge->link) { >> @@ -83,6 +75,14 @@ static int panel_bridge_attach(struct drm_bridge >> *bridge, >> return -EINVAL; >> } >> >> + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) >> + return 0; >> + >> + if (!bridge->encoder) { >> + DRM_ERROR("Missing encoder\n"); > > Shouldn't the device link be deleted in case of error? > Whoops! Yes, that's right. I'm sending a v2 right now. Thanks! Angelo > Regards, > Liu Ying > >> + return -ENODEV; >> + } >> + >> drm_connector_helper_add(connector, >> &panel_bridge_connector_helper_funcs); >> >> -- >> 2.42.0 >
diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index e00d2e94c751..8c507dfd589e 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -67,14 +67,6 @@ static int panel_bridge_attach(struct drm_bridge *bridge, struct drm_device *drm_dev = bridge->dev; int ret; - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) - return 0; - - if (!bridge->encoder) { - DRM_ERROR("Missing encoder\n"); - return -ENODEV; - } - panel_bridge->link = device_link_add(drm_dev->dev, panel->dev, DL_FLAG_STATELESS); if (!panel_bridge->link) { @@ -83,6 +75,14 @@ static int panel_bridge_attach(struct drm_bridge *bridge, return -EINVAL; } + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) + return 0; + + if (!bridge->encoder) { + DRM_ERROR("Missing encoder\n"); + return -ENODEV; + } + drm_connector_helper_add(connector, &panel_bridge_connector_helper_funcs);