All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: fix mutex leak in drm_dp_get_mst_branch_device
@ 2015-10-16 10:33 Adam Richter
  2015-10-16 17:24 ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Adam Richter @ 2015-10-16 10:33 UTC (permalink / raw)
  To: dri-devel

In Linux 4.3-rc5, there is an error case in drm_dp_get_branch_device
that returns without releasing mgr->lock, resulting a spew of kernel
messages about a kernel work function possibly having leaked a mutex
and presumably more serious adverse consequences later.  This patch
changes the error to "goto out" to unlock the mutex before returning.

Signed-off-by: Adam J. Richter <adam_richter2004@yahoo.com>
---

bugzilla.freedesktop.org ticket:
https://bugs.freedesktop.org/show_bug.cgi?id=92480

This patch is against the latest
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git .  I
apologize in advance in I should be submitting patches against some
other reference.  Please feel free to let me know if I should use some
other reference for submitting future patches.

My request to subscribe to dri-devel@lists.freedesktop.org is pending,
so I apologize if it takes a while for this message to be posted on
the mailing list.

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
b/drivers/gpu/drm/drm_dp_mst_topology.c
index bf27a07..018ad7f 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -1194,17 +1194,18 @@ static struct drm_dp_mst_branch
*drm_dp_get_mst_branch_device(struct drm_dp_mst_

                list_for_each_entry(port, &mstb->ports, next) {
                        if (port->port_num == port_num) {
-                               if (!port->mstb) {
+                               mstb = port->mstb;
+                               if (!mstb) {
                                        DRM_ERROR("failed to lookup
MSTB with lct %d, rad %02x\n", lct, rad[0]);
-                                       return NULL;
+                                       goto out;
                                }

-                               mstb = port->mstb;
                                break;
                        }
                }
        }
        kref_get(&mstb->kref);
+ out:
        mutex_unlock(&mgr->lock);
        return mstb;
 }
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: fix mutex leak in drm_dp_get_mst_branch_device
  2015-10-16 10:33 [PATCH] drm: fix mutex leak in drm_dp_get_mst_branch_device Adam Richter
@ 2015-10-16 17:24 ` Daniel Vetter
  2015-10-16 23:24   ` Adam Richter
  2015-10-19  8:14   ` Jani Nikula
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Vetter @ 2015-10-16 17:24 UTC (permalink / raw)
  To: Adam Richter; +Cc: dri-devel

On Fri, Oct 16, 2015 at 03:33:02AM -0700, Adam Richter wrote:
> In Linux 4.3-rc5, there is an error case in drm_dp_get_branch_device
> that returns without releasing mgr->lock, resulting a spew of kernel
> messages about a kernel work function possibly having leaked a mutex
> and presumably more serious adverse consequences later.  This patch
> changes the error to "goto out" to unlock the mutex before returning.
> 
> Signed-off-by: Adam J. Richter <adam_richter2004@yahoo.com>

Patch was whitespace mangled (don't past them into your mailer but instead
send them with git send-email directly, that's safer), so I had to
recreate it.

Applied to drm-misc, thanks.
-Daniel

> ---
> 
> bugzilla.freedesktop.org ticket:
> https://bugs.freedesktop.org/show_bug.cgi?id=92480
> 
> This patch is against the latest
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git .  I
> apologize in advance in I should be submitting patches against some
> other reference.  Please feel free to let me know if I should use some
> other reference for submitting future patches.
> 
> My request to subscribe to dri-devel@lists.freedesktop.org is pending,
> so I apologize if it takes a while for this message to be posted on
> the mailing list.
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index bf27a07..018ad7f 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -1194,17 +1194,18 @@ static struct drm_dp_mst_branch
> *drm_dp_get_mst_branch_device(struct drm_dp_mst_
> 
>                 list_for_each_entry(port, &mstb->ports, next) {
>                         if (port->port_num == port_num) {
> -                               if (!port->mstb) {
> +                               mstb = port->mstb;
> +                               if (!mstb) {
>                                         DRM_ERROR("failed to lookup
> MSTB with lct %d, rad %02x\n", lct, rad[0]);
> -                                       return NULL;
> +                                       goto out;
>                                 }
> 
> -                               mstb = port->mstb;
>                                 break;
>                         }
>                 }
>         }
>         kref_get(&mstb->kref);
> + out:
>         mutex_unlock(&mgr->lock);
>         return mstb;
>  }
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: fix mutex leak in drm_dp_get_mst_branch_device
  2015-10-16 17:24 ` Daniel Vetter
@ 2015-10-16 23:24   ` Adam Richter
  2015-10-19  8:14   ` Jani Nikula
  1 sibling, 0 replies; 4+ messages in thread
From: Adam Richter @ 2015-10-16 23:24 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

Hi, Daniel.

Thank you for your quick handling of my patch submission.

I will look into setting up git send-email.

Adam

On Fri, Oct 16, 2015 at 10:24 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Fri, Oct 16, 2015 at 03:33:02AM -0700, Adam Richter wrote:
>> In Linux 4.3-rc5, there is an error case in drm_dp_get_branch_device
>> that returns without releasing mgr->lock, resulting a spew of kernel
>> messages about a kernel work function possibly having leaked a mutex
>> and presumably more serious adverse consequences later.  This patch
>> changes the error to "goto out" to unlock the mutex before returning.
>>
>> Signed-off-by: Adam J. Richter <adam_richter2004@yahoo.com>
>
> Patch was whitespace mangled (don't past them into your mailer but instead
> send them with git send-email directly, that's safer), so I had to
> recreate it.
>
> Applied to drm-misc, thanks.
> -Daniel
>
>> ---
>>
>> bugzilla.freedesktop.org ticket:
>> https://bugs.freedesktop.org/show_bug.cgi?id=92480
>>
>> This patch is against the latest
>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git .  I
>> apologize in advance in I should be submitting patches against some
>> other reference.  Please feel free to let me know if I should use some
>> other reference for submitting future patches.
>>
>> My request to subscribe to dri-devel@lists.freedesktop.org is pending,
>> so I apologize if it takes a while for this message to be posted on
>> the mailing list.
>>
>> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
>> b/drivers/gpu/drm/drm_dp_mst_topology.c
>> index bf27a07..018ad7f 100644
>> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
>> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
>> @@ -1194,17 +1194,18 @@ static struct drm_dp_mst_branch
>> *drm_dp_get_mst_branch_device(struct drm_dp_mst_
>>
>>                 list_for_each_entry(port, &mstb->ports, next) {
>>                         if (port->port_num == port_num) {
>> -                               if (!port->mstb) {
>> +                               mstb = port->mstb;
>> +                               if (!mstb) {
>>                                         DRM_ERROR("failed to lookup
>> MSTB with lct %d, rad %02x\n", lct, rad[0]);
>> -                                       return NULL;
>> +                                       goto out;
>>                                 }
>>
>> -                               mstb = port->mstb;
>>                                 break;
>>                         }
>>                 }
>>         }
>>         kref_get(&mstb->kref);
>> + out:
>>         mutex_unlock(&mgr->lock);
>>         return mstb;
>>  }
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: fix mutex leak in drm_dp_get_mst_branch_device
  2015-10-16 17:24 ` Daniel Vetter
  2015-10-16 23:24   ` Adam Richter
@ 2015-10-19  8:14   ` Jani Nikula
  1 sibling, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2015-10-19  8:14 UTC (permalink / raw)
  To: Daniel Vetter, Adam Richter; +Cc: dri-devel

On Fri, 16 Oct 2015, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Fri, Oct 16, 2015 at 03:33:02AM -0700, Adam Richter wrote:
>> In Linux 4.3-rc5, there is an error case in drm_dp_get_branch_device
>> that returns without releasing mgr->lock, resulting a spew of kernel
>> messages about a kernel work function possibly having leaked a mutex
>> and presumably more serious adverse consequences later.  This patch
>> changes the error to "goto out" to unlock the mutex before returning.
>> 
>> Signed-off-by: Adam J. Richter <adam_richter2004@yahoo.com>
>
> Patch was whitespace mangled (don't past them into your mailer but instead
> send them with git send-email directly, that's safer), so I had to
> recreate it.
>
> Applied to drm-misc, thanks.

It's missing

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92480
Fixes: 9eb1e57f564d ("drm/dp/mst: take lock around looking up the branch device on hpd irq")
Cc: stable@vger.kernel.org # v4.2+

and arguably was for drm-fixes.

BR,
Jani.



> -Daniel
>
>> ---
>> 
>> bugzilla.freedesktop.org ticket:
>> https://bugs.freedesktop.org/show_bug.cgi?id=92480
>> 
>> This patch is against the latest
>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git .  I
>> apologize in advance in I should be submitting patches against some
>> other reference.  Please feel free to let me know if I should use some
>> other reference for submitting future patches.
>> 
>> My request to subscribe to dri-devel@lists.freedesktop.org is pending,
>> so I apologize if it takes a while for this message to be posted on
>> the mailing list.
>> 
>> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
>> b/drivers/gpu/drm/drm_dp_mst_topology.c
>> index bf27a07..018ad7f 100644
>> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
>> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
>> @@ -1194,17 +1194,18 @@ static struct drm_dp_mst_branch
>> *drm_dp_get_mst_branch_device(struct drm_dp_mst_
>> 
>>                 list_for_each_entry(port, &mstb->ports, next) {
>>                         if (port->port_num == port_num) {
>> -                               if (!port->mstb) {
>> +                               mstb = port->mstb;
>> +                               if (!mstb) {
>>                                         DRM_ERROR("failed to lookup
>> MSTB with lct %d, rad %02x\n", lct, rad[0]);
>> -                                       return NULL;
>> +                                       goto out;
>>                                 }
>> 
>> -                               mstb = port->mstb;
>>                                 break;
>>                         }
>>                 }
>>         }
>>         kref_get(&mstb->kref);
>> + out:
>>         mutex_unlock(&mgr->lock);
>>         return mstb;
>>  }
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2015-10-19  8:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-16 10:33 [PATCH] drm: fix mutex leak in drm_dp_get_mst_branch_device Adam Richter
2015-10-16 17:24 ` Daniel Vetter
2015-10-16 23:24   ` Adam Richter
2015-10-19  8:14   ` Jani Nikula

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.