[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180805200749.116693-14-toddpoynor@gmail.com>
Date: Sun, 5 Aug 2018 13:07:47 -0700
From: Todd Poynor <toddpoynor@...il.com>
To: Rob Springer <rspringer@...gle.com>,
John Joseph <jnjoseph@...gle.com>,
Ben Chan <benchan@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
Todd Poynor <toddpoynor@...gle.com>
Subject: [PATCH 13/15] staging: gasket: core: protect against races during unregister
From: Todd Poynor <toddpoynor@...gle.com>
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@...omium.org>
Signed-off-by: Todd Poynor <toddpoynor@...gle.com>
---
drivers/staging/gasket/gasket_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
index ace92f107ed58..a6462b6d702f1 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);
--
2.18.0.597.ga71716f1ad-goog
Powered by blists - more mailing lists