diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:48:36 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:48:36 -0400 |
commit | f60d2b111cd55c335c2b70e50d66a612d2b10856 (patch) | |
tree | 95ec2063e270ad8f87ab07d507d4c20affacb2a5 /drivers/input | |
parent | 8a3cf456adbde8317a15fc038cfe82c630512f2e (diff) | |
download | op-kernel-dev-f60d2b111cd55c335c2b70e50d66a612d2b10856.zip op-kernel-dev-f60d2b111cd55c335c2b70e50d66a612d2b10856.tar.gz |
Input: reset name, phys and uniq when unregistering
Name, phys and uniq are quite often constant strings in moules implementing
particular input device. If a module unregisters input device and then gets
unloaded, the device could still be present in memory (pinned via sysfs),
but aforementioned members would point to some random memory. Set them all
to NULL when unregistering so sysfs handlers won't try dereferencing them.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/input.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index b149c94..d3cdb13 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -29,6 +29,7 @@ MODULE_DESCRIPTION("Input core"); MODULE_LICENSE("GPL"); EXPORT_SYMBOL(input_allocate_device); +EXPORT_SYMBOL(input_free_device); EXPORT_SYMBOL(input_register_device); EXPORT_SYMBOL(input_unregister_device); EXPORT_SYMBOL(input_register_handler); @@ -872,6 +873,7 @@ struct input_dev *input_allocate_device(void) dev->dynalloc = 1; dev->cdev.class = &input_class; class_device_initialize(&dev->cdev); + mutex_init(&dev->mutex); INIT_LIST_HEAD(&dev->h_list); INIT_LIST_HEAD(&dev->node); } @@ -879,6 +881,18 @@ struct input_dev *input_allocate_device(void) return dev; } +void input_free_device(struct input_dev *dev) +{ + if (dev) { + + mutex_lock(&dev->mutex); + dev->name = dev->phys = dev->uniq = NULL; + mutex_unlock(&dev->mutex); + + input_put_device(dev); + } +} + int input_register_device(struct input_dev *dev) { static atomic_t input_no = ATOMIC_INIT(0); @@ -895,7 +909,6 @@ int input_register_device(struct input_dev *dev) return -EINVAL; } - mutex_init(&dev->mutex); set_bit(EV_SYN, dev->evbit); /* @@ -979,6 +992,10 @@ void input_unregister_device(struct input_dev *dev) sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group); class_device_unregister(&dev->cdev); + mutex_lock(&dev->mutex); + dev->name = dev->phys = dev->uniq = NULL; + mutex_unlock(&dev->mutex); + input_wakeup_procfs_readers(); } |