input: serio: i8042-sparcio.h: Fix refcount leak bug
Subsystems (2)
PATCH v2 1/1 input: serio: i8042-sparcio.h: Fix refcount leak bug
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 <[email protected]>
---
changelog:
v2: use a helper advised by Dmitry
v1: directly add of_node_put() by:
https://lore.kernel.org/all/[email protected]/
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/[email protected]/
drivers/input/serio/i8042-sparcio.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/input/serio/i8042-sparcio.h +14 -6
@@ -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); }
Signature · 1 line
2.25.1