mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: Xin Xiong <xiongx18@fudan.edu.cn>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: Xin Tan <tanxin.ctf@gmail.com>,
	yuanxzhang@fudan.edu.cn, Xiyu Yang <xiyuyang19@fudan.edu.cn>
Subject: Re: [PATCH] drm: fix drm_dp_mst_port refcount leaks in drm_dp_mst_allocate_vcpi
Date: Tue, 04 Aug 2020 12:09:20 -0400	[thread overview]
Message-ID: <69429828565406cca0134b45f98b1879676f0371.camel@redhat.com> (raw)
In-Reply-To: <20200719154545.GA41231@xin-virtual-machine>

Heh, I remember this being mentioned to me way back but completely forgot to
ever go fix it. Thanks for the patch!

Reviewed-by: Lyude Paul <lyude@redhat.com>

This is missing a Fixes: tag though:

   Fixes: 1e797f556c61 ("drm/dp: Split drm_dp_mst_allocate_vcpi")
   Cc: <stable@vger.kernel.org> # v4.12+

So I will go ahead and add that, then push this to drm-misc-next-fixes. Thanks!

On Sun, 2020-07-19 at 23:45 +0800, Xin Xiong wrote:
> drm_dp_mst_allocate_vcpi() invokes
> drm_dp_mst_topology_get_port_validated(), which increases the refcount
> of the "port".
> 
> These reference counting issues take place in two exception handling
> paths separately. Either when “slots” is less than 0 or when
> drm_dp_init_vcpi() returns a negative value, the function forgets to
> reduce the refcnt increased drm_dp_mst_topology_get_port_validated(),
> which results in a refcount leak.
> 
> Fix these issues by pulling up the error handling when "slots" is less
> than 0, and calling drm_dp_mst_topology_put_port() before termination
> when drm_dp_init_vcpi() returns a negative value.
> 
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 1e26b89628f9..97b48b531ec6 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -4261,11 +4261,11 @@ bool drm_dp_mst_allocate_vcpi(struct
> drm_dp_mst_topology_mgr *mgr,
>  {
>  	int ret;
>  
> -	port = drm_dp_mst_topology_get_port_validated(mgr, port);
> -	if (!port)
> +	if (slots < 0)
>  		return false;
>  
> -	if (slots < 0)
> +	port = drm_dp_mst_topology_get_port_validated(mgr, port);
> +	if (!port)
>  		return false;
>  
>  	if (port->vcpi.vcpi > 0) {
> @@ -4281,6 +4281,7 @@ bool drm_dp_mst_allocate_vcpi(struct
> drm_dp_mst_topology_mgr *mgr,
>  	if (ret) {
>  		DRM_DEBUG_KMS("failed to init vcpi slots=%d max=63 ret=%d\n",
>  			      DIV_ROUND_UP(pbn, mgr->pbn_div), ret);
> +		drm_dp_mst_topology_put_port(port);
>  		goto out;
>  	}
>  	DRM_DEBUG_KMS("initing vcpi for pbn=%d slots=%d\n",


      reply	other threads:[~2020-08-04 16:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19 15:45 Xin Xiong
2020-08-04 16:09 ` Lyude Paul [this message]

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=69429828565406cca0134b45f98b1879676f0371.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=tzimmermann@suse.de \
    --cc=xiongx18@fudan.edu.cn \
    --cc=xiyuyang19@fudan.edu.cn \
    --cc=yuanxzhang@fudan.edu.cn \
    /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®