OSDN Git Service

staging: gasket: hold mutex on gasket driver unregistration
authorTodd Poynor <toddpoynor@google.com>
Tue, 17 Jul 2018 20:56:46 +0000 (13:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jul 2018 09:39:47 +0000 (11:39 +0200)
Take the global mutex on driver unregistration updates for proper
ordering of updates and consistent access procedures.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gasket/gasket_core.c

index cbadab7..2ff3286 100644 (file)
@@ -371,7 +371,9 @@ fail1:
        class_destroy(internal->class);
 
 unregister_gasket_driver:
+       mutex_lock(&g_mutex);
        g_descs[desc_idx].driver_desc = NULL;
+       mutex_unlock(&g_mutex);
        return ret;
 }
 EXPORT_SYMBOL(gasket_register_device);
@@ -408,7 +410,9 @@ 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);
 
        gasket_nodev_info("removed %s driver", driver_desc->name);
 }