[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM7PR04MB70466D88048831E48EBBBD0898FAA@AM7PR04MB7046.eurprd04.prod.outlook.com>
Date: Tue, 19 Sep 2023 01:45:45 +0000
From: Ying Liu <victor.liu@....com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
"andrzej.hajda@...el.com" <andrzej.hajda@...el.com>
CC: "neil.armstrong@...aro.org" <neil.armstrong@...aro.org>,
"rfoss@...nel.org" <rfoss@...nel.org>,
"Laurent.pinchart@...asonboard.com"
<Laurent.pinchart@...asonboard.com>,
"jonas@...boo.se" <jonas@...boo.se>,
"jernej.skrabec@...il.com" <jernej.skrabec@...il.com>,
"airlied@...il.com" <airlied@...il.com>,
"daniel@...ll.ch" <daniel@...ll.ch>,
"ulf.hansson@...aro.org" <ulf.hansson@...aro.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel@...labora.com" <kernel@...labora.com>,
"ehristev@...labora.com" <ehristev@...labora.com>,
"wenst@...omium.org" <wenst@...omium.org>
Subject: RE: [PATCH] drm/bridge: panel: Fix device link for
DRM_BRIDGE_ATTACH_NO_CONNECTOR
Hi Angelo,
Thank you for the patch.
On Monday, September 18, 2023 11:01 PM, AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.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@...labora.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
Powered by blists - more mailing lists