* [PATCH] Input: sparcspkr: Fix refcount leak in bbc_beep_probe
@ 2022-05-16 8:10 Miaoqian Lin
2022-05-16 22:08 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Miaoqian Lin @ 2022-05-16 8:10 UTC (permalink / raw)
To: Dmitry Torokhov, Miaoqian Lin, David S. Miller, linux-input,
linux-kernel
of_find_node_by_path() calls of_find_node_opts_by_path(),
which returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add missing of_node_put() to avoid refcount leak.
Fixes: 9c1a5077fdca ("input: Rewrite sparcspkr device probing.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/input/misc/sparcspkr.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index fe43e5557ed7..6a86900aa1fb 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -206,11 +206,11 @@ static int bbc_beep_probe(struct platform_device *op)
info = &state->u.bbc;
info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
if (!info->clock_freq)
- goto out_free;
+ goto out_put;
info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep");
if (!info->regs)
- goto out_free;
+ goto out_put;
platform_set_drvdata(op, state);
@@ -218,11 +218,14 @@ static int bbc_beep_probe(struct platform_device *op)
if (err)
goto out_clear_drvdata;
+ of_node_put(dp);
+
return 0;
out_clear_drvdata:
of_iounmap(&op->resource[0], info->regs, 6);
-
+out_put:
+ of_node_put(dp);
out_free:
kfree(state);
out_err:
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: sparcspkr: Fix refcount leak in bbc_beep_probe
2022-05-16 8:10 [PATCH] Input: sparcspkr: Fix refcount leak in bbc_beep_probe Miaoqian Lin
@ 2022-05-16 22:08 ` Dmitry Torokhov
2022-05-17 5:39 ` Miaoqian Lin
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2022-05-16 22:08 UTC (permalink / raw)
To: Miaoqian Lin; +Cc: David S. Miller, linux-input, linux-kernel
Hi
On Mon, May 16, 2022 at 12:10:16PM +0400, Miaoqian Lin wrote:
> of_find_node_by_path() calls of_find_node_opts_by_path(),
> which returns a node pointer with refcount
> incremented, we should use of_node_put() on it when done.
> Add missing of_node_put() to avoid refcount leak.
>
> Fixes: 9c1a5077fdca ("input: Rewrite sparcspkr device probing.")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
Thank you for the patch.
> drivers/input/misc/sparcspkr.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
> index fe43e5557ed7..6a86900aa1fb 100644
> --- a/drivers/input/misc/sparcspkr.c
> +++ b/drivers/input/misc/sparcspkr.c
> @@ -206,11 +206,11 @@ static int bbc_beep_probe(struct platform_device *op)
> info = &state->u.bbc;
> info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
> if (!info->clock_freq)
> - goto out_free;
> + goto out_put;
>
> info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep");
> if (!info->regs)
> - goto out_free;
> + goto out_put;
>
> platform_set_drvdata(op, state);
>
> @@ -218,11 +218,14 @@ static int bbc_beep_probe(struct platform_device *op)
> if (err)
> goto out_clear_drvdata;
>
> + of_node_put(dp);
> +
We do not really need to keep node pointer for that long, how about the
version of your patch below?
Thanks.
--
Dmitry
Input: sparcspkr - fix refcount leak in bbc_beep_probe
From: Miaoqian Lin <linmq006@gmail.com>
of_find_node_by_path() calls of_find_node_opts_by_path(),
which returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add missing of_node_put() to avoid refcount leak.
Fixes: 9c1a5077fdca ("input: Rewrite sparcspkr device probing.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220516081018.42728-1-linmq006@gmail.com
Patchwork-Id: 12850379
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/misc/sparcspkr.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index fe43e5557ed7..cdcb7737c46a 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -205,6 +205,7 @@ static int bbc_beep_probe(struct platform_device *op)
info = &state->u.bbc;
info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
+ of_node_put(dp);
if (!info->clock_freq)
goto out_free;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: sparcspkr: Fix refcount leak in bbc_beep_probe
2022-05-16 22:08 ` Dmitry Torokhov
@ 2022-05-17 5:39 ` Miaoqian Lin
0 siblings, 0 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-05-17 5:39 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: David S. Miller, linux-input, linux-kernel
Hi, Dmitry
On 2022/5/17 6:08, Dmitry Torokhov wrote:
> Hi
> On Mon, May 16, 2022 at 12:10:16PM +0400, Miaoqian Lin wrote:
>> of_find_node_by_path() calls of_find_node_opts_by_path(),
>> which returns a node pointer with refcount
>> incremented, we should use of_node_put() on it when done.
>> Add missing of_node_put() to avoid refcount leak.
>>
>> Fixes: 9c1a5077fdca ("input: Rewrite sparcspkr device probing.")
>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>> ---
> Thank you for the patch.
>
>> drivers/input/misc/sparcspkr.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
>> index fe43e5557ed7..6a86900aa1fb 100644
>> --- a/drivers/input/misc/sparcspkr.c
>> +++ b/drivers/input/misc/sparcspkr.c
>> @@ -206,11 +206,11 @@ static int bbc_beep_probe(struct platform_device *op)
>> info = &state->u.bbc;
>> info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
>> if (!info->clock_freq)
>> - goto out_free;
>> + goto out_put;
>>
>> info->regs = of_ioremap(&op->resource[0], 0, 6, "bbc beep");
>> if (!info->regs)
>> - goto out_free;
>> + goto out_put;
>>
>> platform_set_drvdata(op, state);
>>
>> @@ -218,11 +218,14 @@ static int bbc_beep_probe(struct platform_device *op)
>> if (err)
>> goto out_clear_drvdata;
>>
>> + of_node_put(dp);
>> +
> We do not really need to keep node pointer for that long, how about the
> version of your patch below?
Looks good to me.
> Thanks.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-17 5:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-16 8:10 [PATCH] Input: sparcspkr: Fix refcount leak in bbc_beep_probe Miaoqian Lin
2022-05-16 22:08 ` Dmitry Torokhov
2022-05-17 5:39 ` Miaoqian Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).