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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  4 Feb 2022 12:20:17 -0800
From:   Stephen Boyd <swboyd@...omium.org>
To:     benjamin.tissoires@...hat.com,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Jiri Kosina <jikos@...nel.org>
Cc:     linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
        "Sean O'Brien" <seobrien@...omium.org>,
        Douglas Anderson <dianders@...omium.org>,
        Zhengqiao Xia <xiazhengqiao@...qin.corp-partner.google.com>
Subject: [PATCH 1/5] Input: atkbd: Convert function_row_physmap to u16 array

This is a u32 array because the device property is an array of u32s.
Convert this to a u16 array to save a little space and to ease the
transition to a common physmap function in the next patch.

Cc: Jiri Kosina <jikos@...nel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: "Sean O'Brien" <seobrien@...omium.org>
Cc: Douglas Anderson <dianders@...omium.org>
Cc: Zhengqiao Xia <xiazhengqiao@...qin.corp-partner.google.com>
Signed-off-by: Stephen Boyd <swboyd@...omium.org>
---

Note this makes a large array on the stack (32 * 24 = 768 bytes). It
could be moved to the heap with a kmalloc or we could accept the extra
16 * 24 = 384 bytes for the vivaldi_data struct if it has a u32, or we
can be more precise and make that a u16 pointer in vivaldi_data and move 
the array to the heap.

 drivers/input/keyboard/atkbd.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index fbdef95291e9..721cde982637 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -237,7 +237,7 @@ struct atkbd {
 	/* Serializes reconnect(), attr->set() and event work */
 	struct mutex mutex;
 
-	u32 function_row_physmap[MAX_FUNCTION_ROW_KEYS];
+	u16 function_row_physmap[MAX_FUNCTION_ROW_KEYS];
 	int num_function_row_keys;
 };
 
@@ -1202,14 +1202,17 @@ static void atkbd_parse_fwnode_data(struct serio *serio)
 {
 	struct atkbd *atkbd = serio_get_drvdata(serio);
 	struct device *dev = &serio->dev;
-	int n;
+	int i, n;
+	u32 physmap[MAX_FUNCTION_ROW_KEYS];
 
 	/* Parse "function-row-physmap" property */
 	n = device_property_count_u32(dev, "function-row-physmap");
 	if (n > 0 && n <= MAX_FUNCTION_ROW_KEYS &&
 	    !device_property_read_u32_array(dev, "function-row-physmap",
-					    atkbd->function_row_physmap, n)) {
+					    physmap, n)) {
 		atkbd->num_function_row_keys = n;
+		for (i = 0; i < n; i++)
+			atkbd->function_row_physmap[i] = physmap[i];
 		dev_dbg(dev, "FW reported %d function-row key locations\n", n);
 	}
 }
-- 
https://chromeos.dev

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ