Messages in this thread |  | | Date | Sun, 14 Oct 2001 19:01:44 +0400 | From | Evgeniy Polyakov <> | Subject | Question about spinlock and timer |
| |
Hello, linux guru.
After reading spinlock documentation at the kernelnewbie.org, i've got a question: If i clearly understand, each kernel timer is connected with some memory region, and this region should be freed when timer becomes clear. And this can occur before spi_lock_bh(). Therefore this memory regin will be freed second time in the loop.
spin_lock_bh(&list_lock);
while (list) { struct foo *next = list->next; del_timer(&list->timer); kfree(list); list = next; } spin_unlock_bh(&list_lock);
This is correct example:
retry: spin_lock_bh(&list_lock);
while (list) { struct foo *next = list->next; if (!del_timer(&list->timer)) { /* Give timer a chance to delete this */ spin_unlock_bh(&list_lock); goto retry; } kfree(list); list = next; }
spin_unlock_bh(&list_lock);
If i was right in previous assumption, than this code may be owervritten in such manner: ..... if (!del_timer(&list->timer)) { if (!next) break; list = next; continue; } .....
Or am I wrong again? If it is so, please tell me the write answer and explanation.
Thanks in advance for you answers and appologies.
--- WBR. //s0mbre - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |