The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD write failure
@ 2026-06-28 13:33 WenTao Liang
  2026-06-29  3:36 ` Kandpal, Suraj
  2026-06-29  4:35 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: WenTao Liang @ 2026-06-28 13:33 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, simona
  Cc: kees, dmitry.baryshkov, tomi.valkeinen, mcanal, vulab,
	suraj.kandpal, dri-devel, linux-kernel, Greg KH, stable

drm_dp_add_mst_branch_device initializes mstb with refcount 1, and
drm_dp_mst_topology_get_mstb increments it to 2. When
drm_dp_dpcd_write_byte fails, out_unlock performs only one
drm_dp_mst_topology_put_mstb, leaving the other reference stored in
mgr->mst_primary. Since MST was not successfully enabled, no disable path
will clean it up.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Fixes: 7a3cbf590e63 ("drm/mst: Some style improvements in drm_dp_mst_topology_mgr_set_mst()")
Cc: stable@vger.kernel.org
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
Changes in v2:
- Fix patch format based on reviewer feedback
---
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c
index 8757972e8e24..db9441c80cd5 100644
--- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
@@ -3679,8 +3679,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
 					     DP_MST_EN |
 					     DP_UP_REQ_EN |
 					     DP_UPSTREAM_IS_SRC);
-		if (ret < 0)
+		if (ret < 0) {
+			mgr->mst_primary = NULL;
 			goto out_unlock;
+		}
 
 		/* Write reset payload */
 		drm_dp_dpcd_clear_payload(mgr->aux);
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD write failure
  2026-06-28 13:33 [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD write failure WenTao Liang
@ 2026-06-29  3:36 ` Kandpal, Suraj
  2026-06-29  4:35 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Kandpal, Suraj @ 2026-06-29  3:36 UTC (permalink / raw)
  To: WenTao Liang, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com,
	simona@ffwll.ch
  Cc: kees@kernel.org, dmitry.baryshkov@oss.qualcomm.com,
	tomi.valkeinen@ideasonboard.com, mcanal@igalia.com,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Greg KH, stable@vger.kernel.org

> Subject: [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD
> write failure
> 
> drm_dp_add_mst_branch_device initializes mstb with refcount 1, and
> drm_dp_mst_topology_get_mstb increments it to 2. When
> drm_dp_dpcd_write_byte fails, out_unlock performs only one
> drm_dp_mst_topology_put_mstb, leaving the other reference stored in
> mgr->mst_primary. Since MST was not successfully enabled, no disable
> mgr->path
> will clean it up.
> 
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> Fixes: 7a3cbf590e63 ("drm/mst: Some style improvements in
> drm_dp_mst_topology_mgr_set_mst()")
> Cc: stable@vger.kernel.org
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>

LGTM,
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>

> ---
> Changes in v2:
> - Fix patch format based on reviewer feedback
> ---
>  drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> index 8757972e8e24..db9441c80cd5 100644
> --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> @@ -3679,8 +3679,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct
> drm_dp_mst_topology_mgr *mgr, bool ms
>  					     DP_MST_EN |
>  					     DP_UP_REQ_EN |
>  					     DP_UPSTREAM_IS_SRC);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			mgr->mst_primary = NULL;
>  			goto out_unlock;
> +		}
> 
>  		/* Write reset payload */
>  		drm_dp_dpcd_clear_payload(mgr->aux);
> --
> 2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD write failure
  2026-06-28 13:33 [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD write failure WenTao Liang
  2026-06-29  3:36 ` Kandpal, Suraj
@ 2026-06-29  4:35 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-06-29  4:35 UTC (permalink / raw)
  To: WenTao Liang
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, kees,
	dmitry.baryshkov, tomi.valkeinen, mcanal, suraj.kandpal,
	dri-devel, linux-kernel, stable

On Sun, Jun 28, 2026 at 09:33:44PM +0800, WenTao Liang wrote:
> drm_dp_add_mst_branch_device initializes mstb with refcount 1, and
> drm_dp_mst_topology_get_mstb increments it to 2. When
> drm_dp_dpcd_write_byte fails, out_unlock performs only one
> drm_dp_mst_topology_put_mstb, leaving the other reference stored in
> mgr->mst_primary. Since MST was not successfully enabled, no disable path
> will clean it up.
> 
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>

I did?  Where did I do that?

> Fixes: 7a3cbf590e63 ("drm/mst: Some style improvements in drm_dp_mst_topology_mgr_set_mst()")
> Cc: stable@vger.kernel.org
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>

Again, you need to document the tools you used to find/fix this with
assisted-by, right?  Please read our documentation for when you use
LLMs.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-29  4:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-28 13:33 [PATCH v2] drm/display: fix MST branch device refcount leak on DPCD write failure WenTao Liang
2026-06-29  3:36 ` Kandpal, Suraj
2026-06-29  4:35 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox