Skip to content

Commit 47245f6

Browse files
author
Desnes Nunes
committed
USB: properly lock dynamic id list when showing an id
JIRA: https://issues.redhat.com/browse/RHEL-78828 commit 81f5c72 Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Date: Wed, 13 Nov 2024 07:49:23 +0100 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> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 07ac0d6 commit 47245f6

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)