summaryrefslogtreecommitdiff
path: root/drivers/usb/common/common.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-11-13 07:49:22 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-11-14 17:05:20 +0100
commit0b3144da31f855fce652303f588416a60991bdef (patch)
treea4069780402b50e6eae4106aa2ca4312eb0ad6b3 /drivers/usb/common/common.c
parent528ea1aca24fba5616f397d43ccb2de99d2a41d7 (diff)
USB: make single lock for all usb dynamic id lists
There are a number of places where we accidentally pass in a constant structure to later cast it off to a dynamic one, and then attempt to grab a lock on it, which is not a good idea. To help resolve this, move the dynamic id lock out of the dynamic id structure for the driver and into one single lock for all USB dynamic ids. As this lock should never have any real contention (it's only every accessed when a device is added or removed, which is always serialized) there should not be any difference except for some memory savings. Note, this just converts the existing use of the dynamic id lock to the new static lock, there is one place that is accessing the dynamic id list without grabbing the lock, that will be fixed up in a follow-on change. Cc: Johan Hovold <johan@kernel.org> Cc: Herve Codina <herve.codina@bootlin.com> Cc: Rob Herring <robh@kernel.org> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Grant Grundler <grundler@chromium.org> Cc: Oliver Neukum <oneukum@suse.com> Cc: Yajun Deng <yajun.deng@linux.dev> Cc: Douglas Anderson <dianders@chromium.org> Cc: linux-usb@vger.kernel.org Link: https://lore.kernel.org/r/2024111322-kindly-finalist-d247@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/common/common.c')
-rw-r--r--drivers/usb/common/common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index b7bea1015d7c..871cf199b6bf 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -415,6 +415,9 @@ EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);
struct dentry *usb_debug_root;
EXPORT_SYMBOL_GPL(usb_debug_root);
+DEFINE_MUTEX(usb_dynids_lock);
+EXPORT_SYMBOL_GPL(usb_dynids_lock);
+
static int __init usb_common_init(void)
{
usb_debug_root = debugfs_create_dir("usb", NULL);