Code problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux