]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
Input: fix input module refcounting
authorDmitry Torokhov <dtor@insightbb.com>
Thu, 14 Sep 2006 05:32:14 +0000 (01:32 -0400)
committerDmitry Torokhov <dtor@insightbb.com>
Thu, 14 Sep 2006 05:32:14 +0000 (01:32 -0400)
Now that input_free_device is basically an alias for input_put_device
we need to acquire a reference to input module right when we allocate
device because input_dev_release releases reference to input module
unconditionally.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/input.c

index 4954c790ccb128fef51ef3895a537ea84a52a84d..f2c85a60a0dcbfe39f39959e28eaf6818327f809 100644 (file)
@@ -912,6 +912,8 @@ struct input_dev *input_allocate_device(void)
                mutex_init(&dev->mutex);
                INIT_LIST_HEAD(&dev->h_list);
                INIT_LIST_HEAD(&dev->node);
+
+               __module_get(THIS_MODULE);
        }
 
        return dev;
@@ -985,8 +987,6 @@ int input_register_device(struct input_dev *dev)
        if (error)
                goto fail3;
 
-       __module_get(THIS_MODULE);
-
        path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
        printk(KERN_INFO "input: %s as %s\n",
                dev->name ? dev->name : "Unspecified device", path ? path : "N/A");