Skip to content

Commit 81f5c72

Browse files
committed
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 <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/2024111324-tubby-facecloth-d4a0@gregkh Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0b3144d commit 81f5c72

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/usb/core/driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf)
116116
struct usb_dynid *dynid;
117117
size_t count = 0;
118118

119+
guard(mutex)(&usb_dynids_lock);
119120
list_for_each_entry(dynid, &dynids->list, node)
120121
if (dynid->id.bInterfaceClass != 0)
121122
count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n",

0 commit comments

Comments
 (0)