From: Peng Fan Date: Mon, 24 Aug 2015 17:42:25 +0000 (-0700) Subject: Input: gpio-keys - report error when disabling unsupported key X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4ea14a53d8f881034fa9e186653821c4e3d9a8fb;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git Input: gpio-keys - report error when disabling unsupported key When trying to disable a key that is not supported by the device we should report error, not do nothing and report success: root@yocto:/sys/devices/soc0/gpio-keys# cat keys 114-116 root@yocto:/sys/devices/soc0/gpio-keys# echo 77 > keys root@yocto:/sys/devices/soc0/gpio-keys# We want 'echo 77 > keys' to report an error, but silence to give us an illusion that all is 'ok'. Signed-off-by: Peng Fan Signed-off-by: Dmitry Torokhov --- diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 1df4507c4c0b..9d517ca7eb5a 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -239,6 +239,11 @@ static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata, } } + if (i == ddata->pdata->nbuttons) { + error = -EINVAL; + goto out; + } + mutex_lock(&ddata->disable_lock); for (i = 0; i < ddata->pdata->nbuttons; i++) {