Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gadgetfs: list_for_each_safe() misuse

really weirdly spelled "while the list is non-empty, pick its
first element, remove it from the list and free it" kind of loop...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 104bb37d 342827d7

+3 -6
+3 -6
drivers/usb/gadget/inode.c
··· 1569 1569 1570 1570 static void destroy_ep_files (struct dev_data *dev) 1571 1571 { 1572 - struct list_head *entry, *tmp; 1573 - 1574 1572 DBG (dev, "%s %d\n", __func__, dev->state); 1575 1573 1576 1574 /* dev->state must prevent interference */ 1577 1575 restart: 1578 1576 spin_lock_irq (&dev->lock); 1579 - list_for_each_safe (entry, tmp, &dev->epfiles) { 1577 + while (!list_empty(&dev->epfiles)) { 1580 1578 struct ep_data *ep; 1581 1579 struct inode *parent; 1582 1580 struct dentry *dentry; 1583 1581 1584 1582 /* break link to FS */ 1585 - ep = list_entry (entry, struct ep_data, epfiles); 1583 + ep = list_first_entry (&dev->epfiles, struct ep_data, epfiles); 1586 1584 list_del_init (&ep->epfiles); 1587 1585 dentry = ep->dentry; 1588 1586 ep->dentry = NULL; ··· 1603 1605 dput (dentry); 1604 1606 mutex_unlock (&parent->i_mutex); 1605 1607 1606 - /* fds may still be open */ 1607 - goto restart; 1608 + spin_lock_irq (&dev->lock); 1608 1609 } 1609 1610 spin_unlock_irq (&dev->lock); 1610 1611 }