Commit 95a2c279 authored by Todd Poynor's avatar Todd Poynor Committed by Greg Kroah-Hartman

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: default avatarGuenter Roeck <groeck@chromium.org>
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 71934948
...@@ -1765,9 +1765,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) ...@@ -1765,9 +1765,9 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc)
break; break;
} }
} }
mutex_unlock(&g_mutex);
if (!internal_desc) { if (!internal_desc) {
mutex_unlock(&g_mutex);
pr_err("request to unregister unknown desc: %s, %d:%d\n", pr_err("request to unregister unknown desc: %s, %d:%d\n",
driver_desc->name, driver_desc->major, driver_desc->name, driver_desc->major,
driver_desc->minor); driver_desc->minor);
...@@ -1780,7 +1780,6 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc) ...@@ -1780,7 +1780,6 @@ void gasket_unregister_device(const struct gasket_driver_desc *driver_desc)
class_destroy(internal_desc->class); class_destroy(internal_desc->class);
/* Finally, effectively "remove" the driver. */ /* Finally, effectively "remove" the driver. */
mutex_lock(&g_mutex);
g_descs[desc_idx].driver_desc = NULL; g_descs[desc_idx].driver_desc = NULL;
mutex_unlock(&g_mutex); mutex_unlock(&g_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment