Commit 104bb37d authored by Al Viro's avatar Al Viro

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 342827d7
...@@ -1569,20 +1569,18 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) ...@@ -1569,20 +1569,18 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
static void destroy_ep_files (struct dev_data *dev) static void destroy_ep_files (struct dev_data *dev)
{ {
struct list_head *entry, *tmp;
DBG (dev, "%s %d\n", __func__, dev->state); DBG (dev, "%s %d\n", __func__, dev->state);
/* dev->state must prevent interference */ /* dev->state must prevent interference */
restart: restart:
spin_lock_irq (&dev->lock); spin_lock_irq (&dev->lock);
list_for_each_safe (entry, tmp, &dev->epfiles) { while (!list_empty(&dev->epfiles)) {
struct ep_data *ep; struct ep_data *ep;
struct inode *parent; struct inode *parent;
struct dentry *dentry; struct dentry *dentry;
/* break link to FS */ /* break link to FS */
ep = list_entry (entry, struct ep_data, epfiles); ep = list_first_entry (&dev->epfiles, struct ep_data, epfiles);
list_del_init (&ep->epfiles); list_del_init (&ep->epfiles);
dentry = ep->dentry; dentry = ep->dentry;
ep->dentry = NULL; ep->dentry = NULL;
...@@ -1605,8 +1603,7 @@ static void destroy_ep_files (struct dev_data *dev) ...@@ -1605,8 +1603,7 @@ static void destroy_ep_files (struct dev_data *dev)
dput (dentry); dput (dentry);
mutex_unlock (&parent->i_mutex); mutex_unlock (&parent->i_mutex);
/* fds may still be open */ spin_lock_irq (&dev->lock);
goto restart;
} }
spin_unlock_irq (&dev->lock); spin_unlock_irq (&dev->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment