The problem with your code is that you have not initialized the event_list element of eventDest structure. As event_list is of list_head type, which is a structure that contains next pointer and previous pointer, these pointers need to be initialized using INIT_LIST_HEAD macro. Or you can do it of your own also by event->event_list->next = event->event_list->prev = event->event_list; Do the following in open function (after getting the memory allocated for eventDest structure): INIT_LIST_HEAD(&(event->event_list)); It will initialize your event_list element of eventDest structure. Try to see the internals of list_head at following link, it will give you good understanding, why your code was crashing. http://lxr.linux.no/source/include/linux/list.h?v=2.4.21#L55 Hope it helps you. Regards, Gaurav -----Original Message----- From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Heap Ho Tan Sent: Saturday, July 24, 2004 9:46 AM To: kernelnewbies@xxxxxxxxxxxx Subject: Code problem Hi, I have the following piece of code for some reason it kept crashing the kernel. struct eventDest { //Single lock for the whole data-structure spinlock_t eventLock; int eventID; //declare a task list int nb_process; wait_queue_head_t queue; struct list_head event_list; }; static spinlock_t event_lock; int event_counter; static LIST_HEAD(event_head); int myeventopen() { struct eventDest *event; struct eventDest tmp; spin_lock_irq(&event_lock); event_counter=event_counter+1; spin_unlock_irq(&event_lock); //printk("Ok up to here\n"); event=(struct eventDest *)kmalloc(sizeof(tmp), GFP_KERNEL); spin_lock_irq(&(event->eventLock)); event->eventID=event_counter; //printk("Ok up to here 2\n"); event->nb_process=0; list_add(&event_head, &(event->event_list)); spin_unlock_irq(&(event->eventLock)); //printk("Ok up to here 3\n"); return event_counter; } -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/