diff options
author | Todd Poynor <toddpoynor@google.com> | 2018-08-05 13:07:47 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-08-08 11:20:07 +0200 |
commit | 95a2c279b2c7c2e59977d5b0773a15ba26b7ce4b (patch) | |
tree | 2b377ae8e6df07631069437051f0a093d6a62b27 /drivers/staging/gasket | |
parent | 71934948b0a18c227de088a40c7660b5ed8cce2c (diff) | |
download | linux-95a2c279b2c7c2e59977d5b0773a15ba26b7ce4b.tar.gz linux-95a2c279b2c7c2e59977d5b0773a15ba26b7ce4b.tar.bz2 linux-95a2c279b2c7c2e59977d5b0773a15ba26b7ce4b.zip |
staging: gasket: core: protect against races during unregister
Keep mutex held across the unregistration operation, until the
driver_desc field of the global table is removed, to prevent a
concurrent accessor from looking up the driver_desc while
gasket_unregister_device() is in the processing of removing it.
Reported-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gasket')
-rw-r--r-- | drivers/staging/gasket/gasket_core.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index ace92f107ed5..a6462b6d702f 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -1765,9 +1765,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) break; } } - mutex_unlock(&g_mutex); if (!internal_desc) { + mutex_unlock(&g_mutex); pr_err("request to unregister unknown desc: %s, %d:%d\n", driver_desc->name, driver_desc->major, driver_desc->minor); @@ -1780,7 +1780,6 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) class_destroy(internal_desc->class); /* Finally, effectively "remove" the driver. */ - mutex_lock(&g_mutex); g_descs[desc_idx].driver_desc = NULL; mutex_unlock(&g_mutex); |