Bug 92480 - [Patch] Linux mutex leak in drm_dp_get_mst_branch
Summary: [Patch] Linux mutex leak in drm_dp_get_mst_branch
Status: RESOLVED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-15 21:08 UTC by Adam J. Richter
Modified: 2015-10-28 12:58 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch to fix mutex leak on error return of drm_dp_get_mst_branch_device in linux-4.3-rc5/drivers/gpu/drm/drm_dp_mst_topology.c (669 bytes, patch)
2015-10-15 21:11 UTC, Adam J. Richter
no flags Details | Splinter Review

Description Adam J. Richter 2015-10-15 21:08:34 UTC
I believe I have found a mutex leak in drm_dp_get_mst_branch_device() in linux/drivers/gpu/drm/drm_dp_mst_topology.c in kernels 4.2-rc1 through the current version, 4.3-rc5, where the function can take an error exit without doing mutex_unlock(&mgr_lock).  I have attached a proposed patch.

Unfortunately, since I made the patch, I have not been able to trigger the error branch that the patch fixes, but I did find the bug by observing that error branch executing and printing an error message that I believe is unique to that branch ("*ERROR* failed to lookup MSTB"):

[   36.944273] [drm:gen8_irq_handler [i915]] *ERROR* The master control interrupt lied (SDE)!
[   74.576811] [drm:drm_dp_get_mst_branch_device [drm_kms_helper]] *ERROR* failed to lookup MSTB with lct 2, rad 10
[   74.587704] BUG: workqueue leaked lock or atomic: kworker/u8:0/0x00000000/6
[   74.587704]      last function: i915_digport_work_func [i915]
[   74.655752] [drm:gen8_irq_handler [i915]] *ERROR* The master control interrupt lied (SDE)!

I think this patch is also arguably an infinitesimal improvement in that it depends less on the optimizer, by reducing two references to port->mstb to one.

Anyhow, if the patch looks good, I would be delighted to if the appropriate person (Dave?) would integrate it for submission upstream.

Thanks in advance for any feedback on this.
Comment 1 Adam J. Richter 2015-10-15 21:11:26 UTC
Created attachment 118904 [details] [review]
Patch to fix mutex leak on error return of drm_dp_get_mst_branch_device in linux-4.3-rc5/drivers/gpu/drm/drm_dp_mst_topology.c
Comment 2 Jani Nikula 2015-10-16 09:43:28 UTC
Please send your (In reply to Adam J. Richter from comment #0)
> Anyhow, if the patch looks good, I would be delighted to if the appropriate
> person (Dave?) would integrate it for submission upstream.

Good catch!

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Please send the patch in proper patch format with your Signed-off-by to dri-devel@lists.freedesktop.org mailing list. See Documentation/SubmittingPatches for help.
Comment 3 Jani Nikula 2015-10-28 12:58:02 UTC
commit 6749c9f023d49adca3ca4773e93282b95ceebfb5
Author: Adam Richter <adamrichter4@gmail.com>
Date:   Fri Oct 16 03:33:02 2015 -0700

    drm: fix mutex leak in drm_dp_get_mst_branch_device
Comment 4 Jani Nikula 2015-10-28 12:58:47 UTC
also cherry-picked to v4.3 as

commit 30730c7f5943b3beace1e29f7f1476e05de3da14
Author: Adam Richter <adamrichter4@gmail.com>
Date:   Fri Oct 16 03:33:02 2015 -0700

    drm: fix mutex leak in drm_dp_get_mst_branch_device


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.