In i8042_platform_init() and i8042_platform_exit(), we should call
of_node_put() for the reference 'root' returned by
of_find_node_by_path() which has increased the refcount.
Fixes: f57caaefacc2 ("[SERIO] i8042-sparcio.h: Convert to of_driver framework.")
Signed-off-by: Liang He <redacted>
---
changelog:
v2: use a helper advised by Dmitry
v1: directly add of_node_put() by:
https://lore.kernel.org/all/20220619073036.4067872-1-windhl@126.com/ (local)
Patched file has been compiled test with:
*make CROSS_COMPILE=sparc64-linux-gnu- ARCH=sparc sparc32_defconfig*
NOTE: this bug has been patched by Yangtao Li but might be with compiled error
https://lore.kernel.org/all/20181215090846.28009-1-tiny.windzz@gmail.com/ (local)
drivers/input/serio/i8042-sparcio.h | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
index fce76812843b..c63186decab6 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -103,12 +103,23 @@ static struct platform_driver sparc_i8042_driver = {
.remove = sparc_i8042_remove,
};
-static int __init i8042_platform_init(void)
+static inline bool i8042_is_mr_coffee(void)
{
struct device_node *root = of_find_node_by_path("/");
const char *name = of_get_property(root, "name", NULL);
+ bool ret = false;
+
+ if (name && !strcmp(name, "SUNW,JavaStation-1"))
+ ret = true;
+
+ of_node_put(root);
+
+ return ret;
+}
- if (name && !strcmp(name, "SUNW,JavaStation-1")) {
+static int __init i8042_platform_init(void)
+{
+ if (i8042_is_mr_coffee()) {
/* Hardcoded values for MrCoffee. */
i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
kbd_iobase = ioremap(0x71300060, 8);@@ -136,10 +147,7 @@ static int __init i8042_platform_init(void)
static inline void i8042_platform_exit(void)
{
- struct device_node *root = of_find_node_by_path("/");
- const char *name = of_get_property(root, "name", NULL);
-
- if (!name || strcmp(name, "SUNW,JavaStation-1"))
+ if (!i8042_is_mr_coffee())
platform_driver_unregister(&sparc_i8042_driver);
}
--
2.25.1