Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 01/10] Input: matrix_keypad - validate GPIO counts against matrix limits
       [not found] <20261123183200.3900004-1-lee@kernel.org>
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 02/10] Input: cyapa - validate firmware image size in cyapa_pip_check_fw() Lee Jones
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Marek Vasut, Arnd Bergmann, Linus Walleij,
	linux-input, linux-kernel
  Cc: stable

matrix_keypad_init_gpio() obtains the row and column GPIO counts via
gpiod_count() and only checks for negative error codes before storing
them in keypad->num_row_gpios and keypad->num_col_gpios.

If firmware supplies more than MATRIX_MAX_ROWS (32) row GPIOs or
MATRIX_MAX_COLS (32) column GPIOs, the setup loops write past the fixed
row_gpios, col_gpios, and row_irqs arrays inside struct matrix_keypad,
and matrix_keypad_scan() overflows the stack-allocated new_state array.
Conversely, a zero count causes get_count_order() to return -1, leading
to an undefined shift when computing row_shift.

Reject non-positive GPIO counts as well as counts exceeding
MATRIX_MAX_ROWS or MATRIX_MAX_COLS, and size col_gpios with
MATRIX_MAX_COLS for consistency.

Fixes: 584bf366f8fa ("Input: matrix_keypad - switch to gpiod API and generic device properties")
Closes: https://sashiko.dev/#/bug/linux-ed4b89af-6c76-4e5f-b140-fb2b107b12d0
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/keyboard/matrix_keypad.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 11018382e84e..c2f839a3de90 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -33,7 +33,7 @@ struct matrix_keypad {
 	struct gpio_desc *row_gpios[MATRIX_MAX_ROWS];
 	unsigned int num_row_gpios;
 
-	struct gpio_desc *col_gpios[MATRIX_MAX_ROWS];
+	struct gpio_desc *col_gpios[MATRIX_MAX_COLS];
 	unsigned int num_col_gpios;
 
 	unsigned int row_irqs[MATRIX_MAX_ROWS];
@@ -302,11 +302,16 @@ static int matrix_keypad_init_gpio(struct platform_device *pdev,
 
 	nrow = gpiod_count(&pdev->dev, "row");
 	ncol = gpiod_count(&pdev->dev, "col");
-	if (nrow < 0 || ncol < 0) {
+	if (nrow <= 0 || ncol <= 0) {
 		dev_err(&pdev->dev, "missing row or column GPIOs\n");
 		return -EINVAL;
 	}
 
+	if (nrow > MATRIX_MAX_ROWS || ncol > MATRIX_MAX_COLS) {
+		dev_err(&pdev->dev, "too many row or column GPIOs\n");
+		return -EINVAL;
+	}
+
 	keypad->num_row_gpios = nrow;
 	keypad->num_col_gpios = ncol;
 
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 02/10] Input: cyapa - validate firmware image size in cyapa_pip_check_fw()
       [not found] <20261123183200.3900004-1-lee@kernel.org>
  2026-11-23 18:31 ` [PATCH 01/10] Input: matrix_keypad - validate GPIO counts against matrix limits Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 03/10] Input: applespi - cancel touchpad registration work on removal Lee Jones
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Sakari Ailus, Dudley Du, linux-input,
	linux-kernel
  Cc: stable

cyapa_pip_check_fw() parses the firmware header, the trailing
application integrity record, and the application rows without verifying
that the supplied firmware buffer is large enough to hold them.

A truncated firmware image smaller than struct cyapa_tsg_bin_image_head
causes an out-of-bounds read in cyapa_pip_fw_head_check() and can
underflow the unsigned size subtraction in
cyapa_get_image_record_data_num().  An image containing a valid header
but zero complete flash records causes image_records[flash_records_count
- 1] to read before the start of fw->data.  Finally, an image whose
metadata specifies an app_len exceeding the available application
records reads past the end of fw->data while computing app_crc.

Validate the header size, ensure at least one flash record is present,
and bound the application row count against the non-integrity record
count before dereferencing image_records.

Fixes: 5812d3067294 ("Input: cyapa - add gen5 trackpad firmware update support")
Closes: https://sashiko.dev/#/bug/linux-cc76de59-950f-4e64-b49e-7605164e02a9
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/mouse/cyapa_gen5.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c
index 59f6e97d5482..bce8104f4149 100644
--- a/drivers/input/mouse/cyapa_gen5.c
+++ b/drivers/input/mouse/cyapa_gen5.c
@@ -1249,6 +1249,11 @@ int cyapa_pip_check_fw(struct cyapa *cyapa, const struct firmware *fw)
 	u16 app_integrity_crc;
 	int i;
 
+	if (fw->size < sizeof(struct cyapa_tsg_bin_image_head)) {
+		dev_err(dev, "%s: firmware image is too small.\n", __func__);
+		return -EINVAL;
+	}
+
 	/* Verify the firmware image not miss-used for Gen5 and Gen6. */
 	if (cyapa_pip_fw_head_check(cyapa,
 		(struct cyapa_tsg_bin_image_head *)fw->data)) {
@@ -1259,6 +1264,11 @@ int cyapa_pip_check_fw(struct cyapa *cyapa, const struct firmware *fw)
 
 	image_records =
 		cyapa_get_image_record_data_num(fw, &flash_records_count);
+	if (flash_records_count <= 0) {
+		dev_err(dev, "%s: firmware image has no flash records.\n",
+			__func__);
+		return -EINVAL;
+	}
 
 	/*
 	 * APP_INTEGRITY row is always the last row block,
@@ -1295,6 +1305,11 @@ int cyapa_pip_check_fw(struct cyapa *cyapa, const struct firmware *fw)
 		return -EINVAL;
 	}
 
+	if (fw_app_len / CYAPA_TSG_FW_ROW_SIZE > flash_records_count - 1) {
+		dev_err(dev, "%s: invalid firmware app length.\n", __func__);
+		return -EINVAL;
+	}
+
 	/* Verify application image CRC. */
 	app_crc = 0xffffU;
 	for (i = 0; i < fw_app_len / CYAPA_TSG_FW_ROW_SIZE; i++) {
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 03/10] Input: applespi - cancel touchpad registration work on removal
       [not found] <20261123183200.3900004-1-lee@kernel.org>
  2026-11-23 18:31 ` [PATCH 01/10] Input: matrix_keypad - validate GPIO counts against matrix limits Lee Jones
  2026-11-23 18:31 ` [PATCH 02/10] Input: cyapa - validate firmware image size in cyapa_pip_check_fw() Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 04/10] Input: matrix_keypad - only stop and start active device across sleep Lee Jones
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Pawel Zalewski, Ronald Tschalär,
	Andy Shevchenko, linux-input, linux-kernel
  Cc: stable

applespi_probe() allocates its driver state with devm_kzalloc_obj() and
initiates an asynchronous touchpad information query whose completion
schedules applespi->work to allocate and register the managed touchpad
input device in applespi_worker().

applespi_remove() disables the ACPI GPE and drains in-flight SPI writes
and reads, but never cancels applespi->work.  If a touchpad info
response scheduled applespi->work just before applespi_drain_reads()
completed, applespi_worker() can run during or after devres teardown,
corrupting the device resource list via devm_input_allocate_device() and
dereferencing freed driver data.

Cancel applespi->work synchronously after applespi_drain_reads(), once
no further SPI responses can schedule it.

Fixes: 038b1a05eae6 ("Input: add Apple SPI keyboard and trackpad driver")
Closes: https://sashiko.dev/#/bug/linux-bb2fd773-6c20-468c-a092-6814f008077f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/keyboard/applespi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index 96c504f28495..d964cd3ee5af 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -1819,6 +1819,7 @@ static void applespi_remove(struct spi_device *spi)
 	device_wakeup_disable(&spi->dev);
 
 	applespi_drain_reads(applespi);
+	cancel_work_sync(&applespi->work);
 
 	debugfs_remove_recursive(applespi->debugfs_root);
 }
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 04/10] Input: matrix_keypad - only stop and start active device across sleep
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (2 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 03/10] Input: applespi - cancel touchpad registration work on removal Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 05/10] Input: stinger - zero-initialise driver state in stinger_connect() Lee Jones
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Marek Vasut, linux-input, linux-kernel; +Cc: stable

matrix_keypad_suspend() and matrix_keypad_resume() unconditionally call
matrix_keypad_stop() and matrix_keypad_start() without holding
input_dev->mutex or checking whether the input device is active.

When the keypad has no open users (or is inhibited), row interrupts are
already disabled and keypad->stopped is true.  Suspending calls
disable_row_irqs() a second time, unbalancing the IRQ disable depth, and
resuming clears keypad->stopped and schedules keypad->work.  If the
device is subsequently unbound while still unopened, Input core skips
the close callback (matrix_keypad_stop()) during unregistration, leaving
keypad->work pending or running after devres frees struct matrix_keypad.

Acquire input_dev->mutex in both sleep callbacks and only stop or start
scanning when input_device_enabled() is true.

Fixes: 7d0f351da460 ("Input: matrix_keypad - switch to using managed resources")
Closes: https://sashiko.dev/#/bug/linux-340f2a74-becb-415d-b1c2-6da8f05a8bd8
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/keyboard/matrix_keypad.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index c2f839a3de90..81507e2a6126 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -268,7 +268,10 @@ static int matrix_keypad_suspend(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
 
-	matrix_keypad_stop(keypad->input_dev);
+	guard(mutex)(&keypad->input_dev->mutex);
+
+	if (input_device_enabled(keypad->input_dev))
+		matrix_keypad_stop(keypad->input_dev);
 
 	if (device_may_wakeup(&pdev->dev))
 		matrix_keypad_enable_wakeup(keypad);
@@ -281,10 +284,13 @@ static int matrix_keypad_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
 
+	guard(mutex)(&keypad->input_dev->mutex);
+
 	if (device_may_wakeup(&pdev->dev))
 		matrix_keypad_disable_wakeup(keypad);
 
-	matrix_keypad_start(keypad->input_dev);
+	if (input_device_enabled(keypad->input_dev))
+		matrix_keypad_start(keypad->input_dev);
 
 	return 0;
 }
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 05/10] Input: stinger - zero-initialise driver state in stinger_connect()
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (3 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 04/10] Input: matrix_keypad - only stop and start active device across sleep Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 06/10] Input: synaptics-rmi4 - check for NULL drvdata in rmi_set_attn_data() Lee Jones
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Vojtech Pavlik, Greg Kroah-Hartman,
	linux-input, linux-kernel
  Cc: stable

stinger_connect() allocates struct stinger with kmalloc_obj() without
initialising the signed packet index stinger->idx.

When serial bytes arrive in stinger_interrupt(), negative values of
stinger->idx pass the stinger->idx < STINGER_MAX_LENGTH check and cause
stinger->data[stinger->idx++] to write before the start of stinger->data
on the heap, corrupting stinger->dev or adjacent slab memory.  Initial
values of 4 or greater never match the stinger->idx == 4 reset check and
permanently wedge packet assembly.

Allocate struct stinger with kzalloc_obj() so stinger->idx and the
packet buffer start zeroed.

Fixes: 17dd3f0f7aa7 ("[PATCH] drivers/input/joystick: convert to dynamic input_dev allocation")
Closes: https://sashiko.dev/#/bug/linux-bad333c0-5b62-4ca5-ad93-204400bcba3a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/joystick/stinger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 011f9b137dca..021216f811c0 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -118,7 +118,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
 	struct input_dev *input_dev;
 	int err = -ENOMEM;
 
-	stinger = kmalloc_obj(*stinger);
+	stinger = kzalloc_obj(*stinger);
 	input_dev = input_allocate_device();
 	if (!stinger || !input_dev)
 		goto fail1;
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 06/10] Input: synaptics-rmi4 - check for NULL drvdata in rmi_set_attn_data()
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (4 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 05/10] Input: stinger - zero-initialise driver state in stinger_connect() Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 07/10] Input: axp20x-pek - skip IRQ handling during sleep without input device Lee Jones
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Benjamin Tissoires, Andrew Duggan,
	linux-input, linux-kernel
  Cc: stable

Transport drivers such as hid-rmi remain registered and continue
delivering attention reports via rmi_set_attn_data() even if the
physical RMI driver failed to probe rmi_dev or was unbound via sysfs.

When rmi_dev is unbound, dev_get_drvdata(&rmi_dev->dev) returns NULL and
rmi_set_attn_data() dereferences drvdata->enabled in interrupt context.

Check that drvdata is non-NULL before accessing drvdata->enabled,
matching rmi_process_interrupt_requests(), rmi_driver_suspend(), and
rmi_driver_resume().

Fixes: b908d3cd812a ("Input: synaptics-rmi4 - allow to add attention data")
Closes: https://sashiko.dev/#/bug/linux-0165ea80-0dcb-4d48-96cf-e2c1532199a0
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/rmi4/rmi_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 7bbe9e801c35..5053c1edad6f 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -172,7 +172,7 @@ void rmi_set_attn_data(struct rmi_device *rmi_dev, unsigned long irq_status,
 	struct rmi4_attn_data attn_data;
 	void *fifo_data;
 
-	if (!drvdata->enabled)
+	if (!drvdata || !drvdata->enabled)
 		return;
 
 	fifo_data = kmemdup(data, size, GFP_ATOMIC);
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 07/10] Input: axp20x-pek - skip IRQ handling during sleep without input device
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (5 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 06/10] Input: synaptics-rmi4 - check for NULL drvdata in rmi_set_attn_data() Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 08/10] Input: mt6779-keypad - enable keypad clock before programming registers Lee Jones
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Chen-Yu Tsai, Carlo Caione, Hans de Goede,
	linux-input, linux-kernel
  Cc: stable

On Cherry Trail systems where an ACPI GPIO button device already handles
the power button, axp20x_pek_should_register_input() returns false and
axp20x_pek_probe() skips axp20x_pek_probe_input_device().  This leaves
axp20x_pek->input NULL and both irq_dbr and irq_dbf zero-initialised.

axp20x_pek_suspend() and axp20x_pek_resume() nevertheless pass irq_dbf
and irq_dbr unconditionally to disable_irq(), enable_irq(), and their
wakeup counterparts, manipulating IRQ 0 (the legacy x86 system timer)
across suspend and resume.

Skip interrupt management in axp20x_pek_suspend() and
axp20x_pek_resume() when no input device was registered.

Fixes: 8a78050ee257 ("Input: axp20x-pek - revert "always register interrupt handlers" change")
Closes: https://sashiko.dev/#/bug/linux-5ae6851f-784e-481c-900b-2e1686578c89
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/misc/axp20x-pek.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index cbbc9db33ad2..a02cdabcf22b 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -329,6 +329,9 @@ static int axp20x_pek_suspend(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 
+	if (!axp20x_pek->input)
+		return 0;
+
 	/*
 	 * As nested threaded IRQs are not automatically disabled during
 	 * suspend, we must explicitly disable non-wakeup IRQs.
@@ -348,6 +351,9 @@ static int axp20x_pek_resume(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 
+	if (!axp20x_pek->input)
+		return 0;
+
 	if (device_may_wakeup(dev)) {
 		disable_irq_wake(axp20x_pek->irq_dbf);
 		disable_irq_wake(axp20x_pek->irq_dbr);
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 08/10] Input: mt6779-keypad - enable keypad clock before programming registers
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (6 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 07/10] Input: axp20x-pek - skip IRQ handling during sleep without input device Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 09/10] Input: pinephone-keyboard - request IRQ before registering input device Lee Jones
  2026-11-23 18:31 ` [PATCH 10/10] Input: wacom_w8001 - use reinit_completion() in w8001_command() Lee Jones
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Mattijs Korpershoek, Dmitry Torokhov, Matthias Brugger,
	AngeloGioacchino Del Regno, Fengping Yu, Marco Felsch,
	Andy Shevchenko, linux-input, linux-kernel, linux-arm-kernel,
	linux-mediatek
  Cc: stable

mt6779_keypad_pdrv_probe() writes the debounce and matrix selection
registers over MMIO before acquiring and enabling the "kpd" clock via
devm_clk_get_enabled().

When the keypad clock is gated off at boot or its clock provider defers
probe, accessing unclocked keypad MMIO registers can trigger a bus abort
or silently drop the configuration writes.

Acquire and enable the "kpd" clock before accessing the keypad
registers.

Fixes: f28af984e771 ("Input: mt6779-keypad - add MediaTek keypad driver")
Closes: https://sashiko.dev/#/bug/linux-fc15622a-407a-48b2-88db-195cdb311dbf
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/keyboard/mt6779-keypad.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/mt6779-keypad.c b/drivers/input/keyboard/mt6779-keypad.c
index 60e6ad97cf59..a9f62f02439e 100644
--- a/drivers/input/keyboard/mt6779-keypad.c
+++ b/drivers/input/keyboard/mt6779-keypad.c
@@ -195,6 +195,10 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev)
 
 	input_set_capability(keypad->input_dev, EV_MSC, MSC_SCAN);
 
+	keypad->clk = devm_clk_get_enabled(&pdev->dev, "kpd");
+	if (IS_ERR(keypad->clk))
+		return PTR_ERR(keypad->clk);
+
 	regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE,
 		     (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK);
 
@@ -208,10 +212,6 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev)
 	regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL,
 			   MTK_KPD_SEL_COLMASK(keypad->n_cols));
 
-	keypad->clk = devm_clk_get_enabled(&pdev->dev, "kpd");
-	if (IS_ERR(keypad->clk))
-		return PTR_ERR(keypad->clk);
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 09/10] Input: pinephone-keyboard - request IRQ before registering input device
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (7 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 08/10] Input: mt6779-keypad - enable keypad clock before programming registers Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  2026-11-23 18:31 ` [PATCH 10/10] Input: wacom_w8001 - use reinit_completion() in w8001_command() Lee Jones
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Samuel Holland, Dmitry Torokhov,
	Uwe Kleine-König (The Capable Hub), Danilo Krummrich,
	Bjorn Helgaas, Takashi Sakamoto, linux-input, linux-kernel
  Cc: stable

ppkb_probe() registers ppkb->input before installing its threaded
interrupt handler with devm_request_threaded_irq().

As soon as input_register_device() exposes the keyboard (including
synchronous open by the console keyboard handler), ppkb_open() enables
matrix scanning.  If a key is held during this window, the controller
asserts its level-triggered interrupt line before the handler is
registered, causing the kernel to disable the unhandled IRQ.  In
addition, devres unwinds in reverse order on unbind, freeing the IRQ
handler before input unregistration invokes ppkb_close() to disable
scanning.

Request the threaded IRQ before calling input_register_device() so the
handler is in place before scanning can be enabled and outlives input
unregistration on teardown.

Fixes: 17406967ec0f ("Input: pinephone-keyboard - add PinePhone keyboard driver")
Closes: https://sashiko.dev/#/bug/linux-f24d8390-cd48-42d7-a3ea-c075b69c127a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/keyboard/pinephone-keyboard.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/input/keyboard/pinephone-keyboard.c b/drivers/input/keyboard/pinephone-keyboard.c
index b4a02ade3a80..fdf2c270bacd 100644
--- a/drivers/input/keyboard/pinephone-keyboard.c
+++ b/drivers/input/keyboard/pinephone-keyboard.c
@@ -412,12 +412,6 @@ static int ppkb_probe(struct i2c_client *client)
 		return error;
 	}
 
-	error = input_register_device(ppkb->input);
-	if (error) {
-		dev_err(dev, "Failed to register input: %d\n", error);
-		return error;
-	}
-
 	error = devm_request_threaded_irq(dev, client->irq,
 					  NULL, ppkb_irq_thread,
 					  IRQF_ONESHOT, client->name, client);
@@ -426,6 +420,12 @@ static int ppkb_probe(struct i2c_client *client)
 		return error;
 	}
 
+	error = input_register_device(ppkb->input);
+	if (error) {
+		dev_err(dev, "Failed to register input: %d\n", error);
+		return error;
+	}
+
 	return 0;
 }
 
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 10/10] Input: wacom_w8001 - use reinit_completion() in w8001_command()
       [not found] <20261123183200.3900004-1-lee@kernel.org>
                   ` (8 preceding siblings ...)
  2026-11-23 18:31 ` [PATCH 09/10] Input: pinephone-keyboard - request IRQ before registering input device Lee Jones
@ 2026-11-23 18:31 ` Lee Jones
  9 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-11-23 18:31 UTC (permalink / raw)
  To: lee, Dmitry Torokhov, Ian Bridges, Cheng, Wacom, Jaya Kumar,
	linux-input, linux-kernel
  Cc: stable

w8001->cmd_done is already initialised in w8001_connect() before opening
the serio port, yet w8001_command() calls init_completion() again for
each command.

Calling init_completion() on an active completion reinitialises its
internal waitqueue spinlock, triggering lockdep warnings and racing with
complete() in w8001_interrupt() if a late response to a previously
timed-out command arrives concurrently.

Use reinit_completion() in w8001_command() instead.

Fixes: 3eb1aa43ef5c ("Input: add support for Wacom W8001 penabled serial touchscreen")
Closes: https://sashiko.dev/#/bug/linux-002efaac-c345-4827-8f1c-7b9d9226c713
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/touchscreen/wacom_w8001.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index d8d1cdc3f09e..a85ef93bdd29 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -362,7 +362,7 @@ static int w8001_command(struct w8001 *w8001, unsigned char command,
 	int rc;
 
 	w8001->response_type = 0;
-	init_completion(&w8001->cmd_done);
+	reinit_completion(&w8001->cmd_done);
 
 	rc = serio_write(w8001->serio, command);
 	if (rc == 0 && wait_response) {
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-23 18:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261123183200.3900004-1-lee@kernel.org>
2026-11-23 18:31 ` [PATCH 01/10] Input: matrix_keypad - validate GPIO counts against matrix limits Lee Jones
2026-11-23 18:31 ` [PATCH 02/10] Input: cyapa - validate firmware image size in cyapa_pip_check_fw() Lee Jones
2026-11-23 18:31 ` [PATCH 03/10] Input: applespi - cancel touchpad registration work on removal Lee Jones
2026-11-23 18:31 ` [PATCH 04/10] Input: matrix_keypad - only stop and start active device across sleep Lee Jones
2026-11-23 18:31 ` [PATCH 05/10] Input: stinger - zero-initialise driver state in stinger_connect() Lee Jones
2026-11-23 18:31 ` [PATCH 06/10] Input: synaptics-rmi4 - check for NULL drvdata in rmi_set_attn_data() Lee Jones
2026-11-23 18:31 ` [PATCH 07/10] Input: axp20x-pek - skip IRQ handling during sleep without input device Lee Jones
2026-11-23 18:31 ` [PATCH 08/10] Input: mt6779-keypad - enable keypad clock before programming registers Lee Jones
2026-11-23 18:31 ` [PATCH 09/10] Input: pinephone-keyboard - request IRQ before registering input device Lee Jones
2026-11-23 18:31 ` [PATCH 10/10] Input: wacom_w8001 - use reinit_completion() in w8001_command() Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox