Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1212102 > unrolled thread

[PATCH] input: gpio-keys: report error when invalid key number

Started byPeng Fan <van.freenix@gmail.com>
First post2015-08-24 14:10 +0200
Last post2015-08-24 19:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] input: gpio-keys: report error when invalid key number Peng Fan <van.freenix@gmail.com> - 2015-08-24 14:10 +0200
    Re: [PATCH] input: gpio-keys: report error when invalid key number Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-08-24 19:50 +0200

#1212102 — [PATCH] input: gpio-keys: report error when invalid key number

FromPeng Fan <van.freenix@gmail.com>
Date2015-08-24 14:10 +0200
Subject[PATCH] input: gpio-keys: report error when invalid key number
Message-ID<q0YJB-7eS-23@gated-at.bofh.it>
When the input key number is not valid one of
'/sys/devices/soc0/gpio-keys/keys', need to report
an error, but not continue.

See the following example:
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 not
silence to give us an fake illusion that all is 'ok'.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/input/keyboard/gpio_keys.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ddf4045..b98f3b4 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++) {
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1212380

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-08-24 19:50 +0200
Message-ID<q142B-6gB-7@gated-at.bofh.it>
In reply to#1212102
On Mon, Aug 24, 2015 at 08:07:44PM +0800, Peng Fan wrote:
> When the input key number is not valid one of
> '/sys/devices/soc0/gpio-keys/keys', need to report
> an error, but not continue.
> 
> See the following example:
> 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 not
> silence to give us an fake illusion that all is 'ok'.
> 
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexander Stein <alexander.stein@systec-electronic.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>

Applied, thank you.

> ---
>  drivers/input/keyboard/gpio_keys.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index ddf4045..b98f3b4 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++) {
> -- 
> 1.8.4.5
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web