[PATCH] linked list insertion bugfix for usb core in 2.6.22.5
Nathael Pajani <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
Randy Dunlap a écrit : > On Thu, 30 Aug 2007 13:56:23 +0200 Nathael Pajani wrote: > >> Hi! >> >> I already wrote for a bugfix in the past (kernel 2.6.20), and I just found the >> bug back in the 2.6.22.5 ! >> I should have used a beter insecticide :) >> (Or maybe I'm doing a mistake, but I don't think so) >> >> The bug is about linked list use in drivers/usb/core/driver.c (see attached >> patch linked_list_insersion_bugfix.patch) > > Please describe the problem that the patch fixes. When you revert the arguments upon a call to list_add_tail(), you do not add a new element to the existant list, but drop all the previously inserted elements, keeping only the head and the new one. This patch fixes this misuse of list_add_tail() in usb_store_new_id(). > Use regular kernel coding style, not your own. That means this: > > - list_add_tail(&dynids->list, &dynid->node); > + list_add_tail( &dynid->node, &dynids->list ); > > should keep the same parentheses/spacing that the old line has. And what if I think that the old spacing is what make the code unreadable and helps people doing this kind of mistakes ? Adding some spaces helps improve readability, so you can clearly iddentify at a glance what are the arguments. But then, this is against the kernel coding style, so I will follow the kernel coding style. Here is the patch: from Nathael Pajani <[email protected]> This patch fixes the order of list_add_tail() arguments in usb_store_new_id() so the list can have more than one single element. Signed-off-by: Nathael Pajani <[email protected]> --- diff -up a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c --- a/drivers/usb/core/driver.c 2007-08-30 20:10:37.000000000 +0100 +++ b/drivers/usb/core/driver.c 2007-08-30 18:29:24.000000000 +0200 @@ -60,7 +60,7 @@ ssize_t usb_store_new_id(struct usb_dyni dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; spin_lock(&dynids->lock); - list_add_tail(&dynids->list, &dynid->node); + list_add_tail(&dynid->node, &dynids->list); spin_unlock(&dynids->lock); if (get_driver(driver)) { ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel