mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Louis Chauvet <louis.chauvet@bootlin.com>
To: Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Naresh Kamboju <naresh.kamboju@linaro.org>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: Hui Pu <Hui.Pu@gehealthcare.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] drm/display: bridge_connector: get/put the panel_bridge
Date: Thu, 30 Oct 2025 15:54:38 +0100	[thread overview]
Message-ID: <8725fc5b-4d29-4fa5-9227-6755fdd9a2e0@bootlin.com> (raw)
In-Reply-To: <20251017-drm-bridge-alloc-getput-bridge-connector-fix-hdmi_cec-v2-3-667abf6d47c0@bootlin.com>



Le 17/10/2025 à 18:15, Luca Ceresoli a écrit :
> The panel_bridge pointer is taken inside the loop and used after the
> loop. Being a local variable, use a cleanup action to ensure it is put on
> return.
> 
> Based on the code structure the panel_bridge pointer might be assigned
> during multiple loop iterations. Even though this is probably not possible
> in the practice, ensure there is no reference leak by putting the reference
> to the old value before overwriting with the new value.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>

> ---
> 
> This patch was added in v2:
> - taking the panel_bridge specific code from the original (buggy) patch,
>    and split it for clarity from the larger patch covering stored bridge
>    pointers
> - comapred to the original code, added drm_bridge_put() for extra safety
>    even though likely not necessary
> ---
>   drivers/gpu/drm/display/drm_bridge_connector.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c
> index 95ccf86527129edaa6fcc75c6202985e73c46da8..a2d30cf9e06df44b89456b5aba8198ee1e5d5601 100644
> --- a/drivers/gpu/drm/display/drm_bridge_connector.c
> +++ b/drivers/gpu/drm/display/drm_bridge_connector.c
> @@ -652,7 +652,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
>   	struct drm_bridge_connector *bridge_connector;
>   	struct drm_connector *connector;
>   	struct i2c_adapter *ddc = NULL;
> -	struct drm_bridge *panel_bridge = NULL;
> +	struct drm_bridge *panel_bridge __free(drm_bridge_put) = NULL;
>   	unsigned int supported_formats = BIT(HDMI_COLORSPACE_RGB);
>   	unsigned int max_bpc = 8;
>   	bool support_hdcp = false;
> @@ -787,8 +787,10 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
>   		if (bridge->ddc)
>   			ddc = bridge->ddc;
>   
> -		if (drm_bridge_is_panel(bridge))
> -			panel_bridge = bridge;
> +		if (drm_bridge_is_panel(bridge)) {
> +			drm_bridge_put(panel_bridge);
> +			panel_bridge = drm_bridge_get(bridge);
> +		}
>   
>   		if (bridge->support_hdcp)
>   			support_hdcp = true;
> 

-- 
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


  reply	other threads:[~2025-10-30 14:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20251017162527eucas1p164f6590949b2149a16c670b7991051cf@eucas1p1.samsung.com>
2025-10-17 16:15 ` [PATCH v2 0/3] drm/display: bridge_connector: get/put the stored bridges: fix NULL pointer regression Luca Ceresoli
2025-10-17 16:15   ` [PATCH v2 1/3] Revert "drm/display: bridge_connector: get/put the stored bridges" Luca Ceresoli
2025-10-30 13:11     ` Mark Brown
2025-10-30 15:25       ` Luca Ceresoli
2025-10-30 14:51     ` Louis Chauvet
2025-10-17 16:15   ` [PATCH v2 2/3] drm/display: bridge_connector: get/put the stored bridges Luca Ceresoli
2025-10-30 14:53     ` Louis Chauvet
2025-10-17 16:15   ` [PATCH v2 3/3] drm/display: bridge_connector: get/put the panel_bridge Luca Ceresoli
2025-10-30 14:54     ` Louis Chauvet [this message]
2025-10-17 21:54   ` [PATCH v2 0/3] drm/display: bridge_connector: get/put the stored bridges: fix NULL pointer regression Marek Szyprowski
2025-10-23 13:01   ` Tommaso Merciai
2025-10-27 14:44   ` Nicolas Frattaroli
2025-10-28  8:56   ` Geert Uytterhoeven
2025-11-03  5:20   ` Dmitry Baryshkov
2025-11-03 11:52   ` Luca Ceresoli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8725fc5b-4d29-4fa5-9227-6755fdd9a2e0@bootlin.com \
    --to=louis.chauvet@bootlin.com \
    --cc=Hui.Pu@gehealthcare.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=m.szyprowski@samsung.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®