On Sun, Feb 27, 2011 at 11:57, Sameer Rahmani <lxsameer@xxxxxxxxx> wrote: > static int __init module_initial(void) > { > dev_t dev; > int result; > struct memmap *memory; > > if (major) > { > dev = MKDEV(major, minor); > result = register_chrdev_region(dev, 1, "memchar"); > } > else > { > result = alloc_chrdev_region(&dev, minor, 1, > "memchar"); > major = MAJOR(dev); > > } > if (result < 0) > { > printk (KERN_ALERT "Cannot register major number.\n"); > return result; > } > > device = kmalloc(sizeof(char) * map_size, GFP_KERNEL); > if (! device) > { > printk (KERN_ALERT "Allocating device failed.\n"); > result = -ENOMEM; > goto fail; > } > > > memset(device, 0, sizeof(char) * map_size); > > memory->device = device; > mem_setup_cdev(memory); > > > printk(KERN_ALERT "Major: %d", major); > return 0; > > fail: > module_cleanup(); > return result; > } As you can see by yourself, you put many data structures as locals to module_init. So once module_init is thrashed, those variables/pointers also gone. Result? Easy to guess...lost reference :) -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies