On Tue, Jul 11, 2006 at 06:09:38PM +0200, Fernando Apestegu?a wrote: > Hi, > > I would like to know how to free a list_head. > > I have almost 200 elements and I'm wonder if I must traverse the list for > all the elements and do: > > list_for_each(...){ > my_entry=list_entry(....) > list_del(my_entry) > kfree(my_entry) > } > > Should I do this in this way? No, try this instead: list_for_each_entry_safe(...) { list_del(my_entry); kfree(my_entry); } The main point is the _safe usage if you are traversing a list and deleting items from it at the same time. Hope this helps, greg k-h -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/