lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1440418064-15971-1-git-send-email-van.freenix@gmail.com>
Date:	Mon, 24 Aug 2015 20:07:44 +0800
From:	Peng Fan <van.freenix@...il.com>
To:	dmitry.torokhov@...il.com
Cc:	linus.walleij@...aro.org, linux-input@...r.kernel.org,
	linux-kernel@...r.kernel.org, van.freenix@...il.com,
	Alexander Stein <alexander.stein@...tec-electronic.com>,
	Tejun Heo <tj@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Wolfram Sang <wsa@...-dreams.de>,
	Fabio Estevam <fabio.estevam@...escale.com>
Subject: [PATCH] input: gpio-keys: report error when invalid key number

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@...to:/sys/devices/soc0/gpio-keys# cat keys
114-116
root@...to:/sys/devices/soc0/gpio-keys# echo 77 > keys
root@...to:/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@...il.com>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Linus Walleij <linus.walleij@...aro.org>
Cc: Alexander Stein <alexander.stein@...tec-electronic.com>
Cc: Tejun Heo <tj@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Wolfram Sang <wsa@...-dreams.de>
Cc: Fabio Estevam <fabio.estevam@...escale.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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ