aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-01-08 16:13:28 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-03-20 21:29:50 -0400
commit104bb37d3e0eb576b6aa61b9ed909e118e026bd2 (patch)
tree904391317ad07afccc583b2c161a093c44b8aa60 /drivers
parent342827d7d19cb52b562bb3efeb4d4b672d008c35 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/inode.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index c95eea43b637..f701afb349ee 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1569,20 +1569,18 @@ delegate:
1569 1569
1570static void destroy_ep_files (struct dev_data *dev) 1570static void destroy_ep_files (struct dev_data *dev)
1571{ 1571{
1572 struct list_head *entry, *tmp;
1573
1574 DBG (dev, "%s %d\n", __func__, dev->state); 1572 DBG (dev, "%s %d\n", __func__, dev->state);
1575 1573
1576 /* dev->state must prevent interference */ 1574 /* dev->state must prevent interference */
1577restart: 1575restart:
1578 spin_lock_irq (&dev->lock); 1576 spin_lock_irq (&dev->lock);
1579 list_for_each_safe (entry, tmp, &dev->epfiles) { 1577 while (!list_empty(&dev->epfiles)) {
1580 struct ep_data *ep; 1578 struct ep_data *ep;
1581 struct inode *parent; 1579 struct inode *parent;
1582 struct dentry *dentry; 1580 struct dentry *dentry;
1583 1581
1584 /* break link to FS */ 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 list_del_init (&ep->epfiles); 1584 list_del_init (&ep->epfiles);
1587 dentry = ep->dentry; 1585 dentry = ep->dentry;
1588 ep->dentry = NULL; 1586 ep->dentry = NULL;
@@ -1605,8 +1603,7 @@ restart:
1605 dput (dentry); 1603 dput (dentry);
1606 mutex_unlock (&parent->i_mutex); 1604 mutex_unlock (&parent->i_mutex);
1607 1605
1608 /* fds may still be open */ 1606 spin_lock_irq (&dev->lock);
1609 goto restart;
1610 } 1607 }
1611 spin_unlock_irq (&dev->lock); 1608 spin_unlock_irq (&dev->lock);
1612} 1609}