On Wed, 12 Nov 2008 00:17:39 +0200Ohhh i see what you mean
Izik Eidus <ieidus@xxxxxxxxxx> wrote:
Yes, I am taking get_task_mm() if the module will be removed before i free the mms, things will go wrong+static int ksm_dev_open(struct inode *inode, struct file *filp)Why do you roll your own module reference counting? Is there a
+{
+ try_module_get(THIS_MODULE);
+ return 0;
+}
+
+static int ksm_dev_release(struct inode *inode, struct file *filp)
+{
+ module_put(THIS_MODULE);
+ return 0;
+}
+
+static struct file_operations ksm_chardev_ops = {
+ .open = ksm_dev_open,
+ .release = ksm_dev_release,
+ .unlocked_ioctl = ksm_dev_ioctl,
+ .compat_ioctl = ksm_dev_ioctl,
+};
reason you don't just set .owner and let the VFS handle it?
But...if you set .owner, the VFS will do the try_module_get() *before*
calling into your module (as an added bonus, it will actually check the
return value too).