Thread (2 messages) flat view 2 messages, 2 authors, 3d ago
WARM3d

[PATCH] Input: Fix i2c_bus OF node reference leak in ppkb_probe()

From: Wentao Liang <hidden>
Date: 2026-09-16 18:47:52
Also in: lkml, stable
Subsystem: input (keyboard, mouse, joystick, touchscreen) drivers, pine64 pinephone keyboard driver, the rest · Maintainers: Dmitry Torokhov, Samuel Holland, Linus Torvalds

The device node reference returned by of_get_child_by_name() is
stored as the adapter's of_node but never released, leaking one node
reference on every probe, successful or not.

The adapter only borrows the node, so drop the reference once the
adapter has been added, and also on the error path.

Fixes: 63c5eb157cfd ("Input: pinephone-keyboard - support the proxied I2C bus")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <redacted>
---
 drivers/input/keyboard/pinephone-keyboard.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/input/keyboard/pinephone-keyboard.c b/drivers/input/keyboard/pinephone-keyboard.c
index 147b1f288a33..c82323713be8 100644
--- a/drivers/input/keyboard/pinephone-keyboard.c
+++ b/drivers/input/keyboard/pinephone-keyboard.c
@@ -384,8 +384,10 @@ static int ppkb_probe(struct i2c_client *client)
 		error = devm_i2c_add_adapter(dev, &ppkb->adapter);
 		if (error) {
 			dev_err(dev, "Failed to add I2C adapter: %d\n", error);
+			of_node_put(i2c_bus);
 			return error;
 		}
+		of_node_put(i2c_bus);
 	}
 
 	crc8_populate_msb(ppkb->crc_table, PPKB_CRC8_POLYNOMIAL);
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help