[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2024111324-tubby-facecloth-d4a0@gregkh>
Date: Wed, 13 Nov 2024 07:49:23 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-usb@...r.kernel.org
Cc: stern@...land.harvard.edu,
gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/2] USB: properly lock dynamic id list when showing an id
When walking the list of dynamic ids for a driver, no lock was being
held, which meant that an id could be removed or added while the list
was being iterated. Fix this up by properly grabing the lock while we
walk the list.
Reported-by: Alan Stern <stern@...land.harvard.edu>
Cc: linux-usb@...r.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
v2. - new patch in v2, not in v1 series, based on review of v1.
drivers/usb/core/driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index bc3c00580238..9ea955a3d115 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -116,6 +116,7 @@ ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf)
struct usb_dynid *dynid;
size_t count = 0;
+ guard(mutex)(&usb_dynids_lock);
list_for_each_entry(dynid, &dynids->list, node)
if (dynid->id.bInterfaceClass != 0)
count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n",
--
2.47.0
Powered by blists - more mailing lists