2022-06-19 07:42:28

by Liang He

[permalink] [raw]
Subject: [PATCH] input/serio: Fix refcount leak bug in i8042-sparcio

In i8042_platform_init() and i8042_platform_exit(), we need call
of_node_put() to keep refcount balance.

Signed-off-by: Liang He <[email protected]>
---
drivers/input/serio/i8042-sparcio.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
index fce76812843b..a2a9db9220d7 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -108,6 +108,8 @@ static int __init i8042_platform_init(void)
struct device_node *root = of_find_node_by_path("/");
const char *name = of_get_property(root, "name", NULL);

+ of_node_put(root);
+
if (name && !strcmp(name, "SUNW,JavaStation-1")) {
/* Hardcoded values for MrCoffee. */
i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
@@ -139,6 +141,8 @@ 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);

+ of_node_put(root);
+
if (!name || strcmp(name, "SUNW,JavaStation-1"))
platform_driver_unregister(&sparc_i8042_driver);
}
--
2.25.1


2022-07-09 06:05:20

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] input/serio: Fix refcount leak bug in i8042-sparcio

Hi Liang,

On Sun, Jun 19, 2022 at 03:30:36PM +0800, Liang He wrote:
> In i8042_platform_init() and i8042_platform_exit(), we need call
> of_node_put() to keep refcount balance.
>
> Signed-off-by: Liang He <[email protected]>
> ---
> drivers/input/serio/i8042-sparcio.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
> index fce76812843b..a2a9db9220d7 100644
> --- a/drivers/input/serio/i8042-sparcio.h
> +++ b/drivers/input/serio/i8042-sparcio.h
> @@ -108,6 +108,8 @@ static int __init i8042_platform_init(void)
> struct device_node *root = of_find_node_by_path("/");
> const char *name = of_get_property(root, "name", NULL);
>
> + of_node_put(root);
> +
> if (name && !strcmp(name, "SUNW,JavaStation-1")) {
> /* Hardcoded values for MrCoffee. */
> i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
> @@ -139,6 +141,8 @@ 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);
>
> + of_node_put(root);
> +
> if (!name || strcmp(name, "SUNW,JavaStation-1"))
> platform_driver_unregister(&sparc_i8042_driver);
> }

There already was an attempt to fix this issue in a slightly better way,
unfortunately the original author did not finish the work:

https://lore.kernel.org/all/[email protected]/

Thanks.

--
Dmitry

2022-07-10 02:12:34

by Liang He

[permalink] [raw]
Subject: Re:Re: [PATCH] input/serio: Fix refcount leak bug in i8042-sparcio






At 2022-07-09 12:49:23, "Dmitry Torokhov" <[email protected]> wrote:
>Hi Liang,
>
>On Sun, Jun 19, 2022 at 03:30:36PM +0800, Liang He wrote:
>> In i8042_platform_init() and i8042_platform_exit(), we need call
>> of_node_put() to keep refcount balance.
>>
>> Signed-off-by: Liang He <[email protected]>
>> ---
>> drivers/input/serio/i8042-sparcio.h | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
>> index fce76812843b..a2a9db9220d7 100644
>> --- a/drivers/input/serio/i8042-sparcio.h
>> +++ b/drivers/input/serio/i8042-sparcio.h
>> @@ -108,6 +108,8 @@ static int __init i8042_platform_init(void)
>> struct device_node *root = of_find_node_by_path("/");
>> const char *name = of_get_property(root, "name", NULL);
>>
>> + of_node_put(root);
>> +
>> if (name && !strcmp(name, "SUNW,JavaStation-1")) {
>> /* Hardcoded values for MrCoffee. */
>> i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
>> @@ -139,6 +141,8 @@ 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);
>>
>> + of_node_put(root);
>> +
>> if (!name || strcmp(name, "SUNW,JavaStation-1"))
>> platform_driver_unregister(&sparc_i8042_driver);
>> }
>
>There already was an attempt to fix this issue in a slightly better way,
>unfortunately the original author did not finish the work:
>
>https://lore.kernel.org/all/[email protected]/
>
>Thanks.
>
>--
>Dmitry

Hi, Dmirtry,

Thanks for reviewing my patch code.

The Li's patch adds a helper and is better than mine.

Thanks again,

Liang

2022-07-11 03:27:46

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: Re: [PATCH] input/serio: Fix refcount leak bug in i8042-sparcio

On Sun, Jul 10, 2022 at 09:37:10AM +0800, Liang He wrote:
> At 2022-07-09 12:49:23, "Dmitry Torokhov" <[email protected]> wrote:
> >Hi Liang,
> >
> >On Sun, Jun 19, 2022 at 03:30:36PM +0800, Liang He wrote:
> >> In i8042_platform_init() and i8042_platform_exit(), we need call
> >> of_node_put() to keep refcount balance.
> >>
> >> Signed-off-by: Liang He <[email protected]>
> >> ---
> >> drivers/input/serio/i8042-sparcio.h | 4 ++++
> >> 1 file changed, 4 insertions(+)
> >>
> >> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
> >> index fce76812843b..a2a9db9220d7 100644
> >> --- a/drivers/input/serio/i8042-sparcio.h
> >> +++ b/drivers/input/serio/i8042-sparcio.h
> >> @@ -108,6 +108,8 @@ static int __init i8042_platform_init(void)
> >> struct device_node *root = of_find_node_by_path("/");
> >> const char *name = of_get_property(root, "name", NULL);
> >>
> >> + of_node_put(root);
> >> +
> >> if (name && !strcmp(name, "SUNW,JavaStation-1")) {
> >> /* Hardcoded values for MrCoffee. */
> >> i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
> >> @@ -139,6 +141,8 @@ 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);
> >>
> >> + of_node_put(root);
> >> +
> >> if (!name || strcmp(name, "SUNW,JavaStation-1"))
> >> platform_driver_unregister(&sparc_i8042_driver);
> >> }
> >
> >There already was an attempt to fix this issue in a slightly better way,
> >unfortunately the original author did not finish the work:
> >
> >https://lore.kernel.org/all/[email protected]/
> >
> >Thanks.
> >
> >--
> >Dmitry
>
> Hi, Dmirtry,
>
> Thanks for reviewing my patch code.
>
> The Li's patch adds a helper and is better than mine.

Right, however there is a compile error in Li's version. It would be
great if someone could finish their work.

Thanks.

--
Dmitry

2022-07-11 05:12:37

by Liang He

[permalink] [raw]
Subject: Re:Re: Re: [PATCH] input/serio: Fix refcount leak bug in i8042-sparcio





At 2022-07-11 11:19:20, "Dmitry Torokhov" <[email protected]> wrote:
>On Sun, Jul 10, 2022 at 09:37:10AM +0800, Liang He wrote:
>> At 2022-07-09 12:49:23, "Dmitry Torokhov" <[email protected]> wrote:
>> >Hi Liang,
>> >
>> >On Sun, Jun 19, 2022 at 03:30:36PM +0800, Liang He wrote:
>> >> In i8042_platform_init() and i8042_platform_exit(), we need call
>> >> of_node_put() to keep refcount balance.
>> >>
>> >> Signed-off-by: Liang He <[email protected]>
>> >> ---
>> >> drivers/input/serio/i8042-sparcio.h | 4 ++++
>> >> 1 file changed, 4 insertions(+)
>> >>
>> >> diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
>> >> index fce76812843b..a2a9db9220d7 100644
>> >> --- a/drivers/input/serio/i8042-sparcio.h
>> >> +++ b/drivers/input/serio/i8042-sparcio.h
>> >> @@ -108,6 +108,8 @@ static int __init i8042_platform_init(void)
>> >> struct device_node *root = of_find_node_by_path("/");
>> >> const char *name = of_get_property(root, "name", NULL);
>> >>
>> >> + of_node_put(root);
>> >> +
>> >> if (name && !strcmp(name, "SUNW,JavaStation-1")) {
>> >> /* Hardcoded values for MrCoffee. */
>> >> i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
>> >> @@ -139,6 +141,8 @@ 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);
>> >>
>> >> + of_node_put(root);
>> >> +
>> >> if (!name || strcmp(name, "SUNW,JavaStation-1"))
>> >> platform_driver_unregister(&sparc_i8042_driver);
>> >> }
>> >
>> >There already was an attempt to fix this issue in a slightly better way,
>> >unfortunately the original author did not finish the work:
>> >
>> >https://lore.kernel.org/all/[email protected]/
>> >
>> >Thanks.
>> >
>> >--
>> >Dmitry
>>
>> Hi, Dmirtry,
>>
>> Thanks for reviewing my patch code.
>>
>> The Li's patch adds a helper and is better than mine.
>
>Right, however there is a compile error in Li's version. It would be
>great if someone could finish their work.
>
>Thanks.
>
>--
>Dmitry


Thanks,

I'd like to continue Li's work and complete it soon.

Liang