mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
Input: make sure input handlers define only one processing method
Input core expects input handlers to be either filters, or regular handlers, but not both. Additionally, for regular handlers it does not make sense to define both single event method and batch method. Refuse registering handler if it defines more than one method. Reviewed-by: Jeff LaBundy <jeff@labundy.com> Reviewed-by: Benjamin Tissoires <bentiss@kernel.org> Link: https://lore.kernel.org/r/20240703213756.3375978-3-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
b3d65108ac
commit
a184cf98b1
@ -2517,6 +2517,26 @@ void input_unregister_device(struct input_dev *dev)
|
||||
}
|
||||
EXPORT_SYMBOL(input_unregister_device);
|
||||
|
||||
static int input_handler_check_methods(const struct input_handler *handler)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (handler->filter)
|
||||
count++;
|
||||
if (handler->events)
|
||||
count++;
|
||||
if (handler->event)
|
||||
count++;
|
||||
|
||||
if (count > 1) {
|
||||
pr_err("%s: only one event processing method can be defined (%s)\n",
|
||||
__func__, handler->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* input_register_handler - register a new input handler
|
||||
* @handler: handler to be registered
|
||||
@ -2530,6 +2550,10 @@ int input_register_handler(struct input_handler *handler)
|
||||
struct input_dev *dev;
|
||||
int error;
|
||||
|
||||
error = input_handler_check_methods(handler);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = mutex_lock_interruptible(&input_mutex);
|
||||
if (error)
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user