mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
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@rowland.harvard.edu> Cc: linux-usb@vger.kernel.org Link: https://lore.kernel.org/r/2024111324-tubby-facecloth-d4a0@gregkh Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0b3144da31
commit
81f5c72d04
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user