lkml.org 
[lkml]   [2018]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 06/18] staging: gasket: fix deadlock in pci driver unregister path
On Sat, Jul 14, 2018 at 8:58 AM Todd Poynor <toddpoynor@gmail.com> wrote:
>
> From: Todd Poynor <toddpoynor@google.com>
>
> g_mutex held across pci_unregister_driver() call, also held in
> gasket_pci_remove(), which deadlocks.
>
> Reported-by: Dmitry Torokhov <dtor@chromium.org>
> Signed-off-by: Zhongze Hu <frankhu@chromium.org>
> Signed-off-by: Todd Poynor <toddpoynor@google.com>
> ---
> drivers/staging/gasket/gasket_core.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
> index 3bdf7d36b397..6d240dc59557 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -668,13 +668,10 @@ static void gasket_pci_remove(struct pci_dev *pci_dev)
> struct gasket_dev *gasket_dev = NULL;
> const struct gasket_driver_desc *driver_desc;
> /* Find the device desc. */
> - mutex_lock(&g_mutex);
> + __must_hold(&g_mutex);

And what exactly ensures that mutex is held here? Yes, we are holding
the mutex when we unload the driver, but PCI hot-unplug or unbinding
the device though sysfs do not go through module unload code path, so
you'll end up here without holding the mutex.

> internal_desc = lookup_internal_desc(pci_dev);
> - if (!internal_desc) {
> - mutex_unlock(&g_mutex);
> + if (!internal_desc)
> return;
> - }
> - mutex_unlock(&g_mutex);
>
> driver_desc = internal_desc->driver_desc;

Thanks,
Dmitry
\
 
 \ /
  Last update: 2018-07-15 22:07    [W:0.213 / U:1.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site