> > +static void delete_sysfs_entry(void)
> > +{
> > +       struct efivars *efivars = &__efivars;
> > +       struct efivar_entry *entry, *n;
> > +       efi_status_t status;
> > +       unsigned long flags;
> > +
> > +       list_for_each_entry_safe(entry, n, &efivars->list, list) {
> 
> This ->lock here is protecting this list, so it isn't correct to grab the 
> lock within iteration.  The lock should instead be grabbed before
> iterating through the list, dropped if we need to unregister and iteration 
> should restart completely if the lock was dropped.
> 

Thank you for your comment.
If my understanding is correct, the code should be changed as follows.

+       while (1) {
+               found = NULL;
+               spin_lock_irqsave(&efivars->lock, flags);
+               list_for_each_entry(entry, &efivars->list, list) {
+                       status = get_var_data_locked(efivars, &entry->var);
+                       if (status != EFI_SUCCESS) {
+                               found = entry;
+                               list_del(&entry->list);
+                               break;
+                       }
+               }
+               spin_unlock_irqrestore(&efivars->lock, flags);
+               if (found)
+                       efivar_unregister(entry);
+               else
+                       break;
+       }

> > +               spin_lock_irqsave(&efivars->lock, flags);
> > +               status = get_var_data_locked(efivars, &entry->var);
> > +               if (status != EFI_SUCCESS) {
> > +                       list_del(&entry->list);
> > +                       spin_unlock_irqrestore(&efivars->lock, flags);
> > +                       efivar_unregister(entry);
> > +               } else
> > +                       spin_unlock_irqrestore(&efivars->lock, flags);
> > +       }
> > +}
> > +       /* Delete unavailable sysfs entries */
> > +       delete_sysfs_entry();
> 
> This method needs a better name that reflects what it is doing.
> delete_all_stale_sysfs_entries ?

OK. I will change the name to it.

Seiji

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to