* [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put()
@ 2022-06-16 4:49 Liang He
2022-06-16 5:54 ` Liang He
2022-06-16 6:28 ` Conor.Dooley
0 siblings, 2 replies; 5+ messages in thread
From: Liang He @ 2022-06-16 4:49 UTC (permalink / raw)
To: palmer, paul.walmsley, aou
Cc: windhl, linux-riscv, linux-kernel, kernel test robot
In sifive_l2_init(), of_find_matching_node() will return a node pointer
with refcount incremented. We should use of_node_put() in each fail path
or when it is not used anymore.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Liang He <windhl@126.com>
---
changelog:
v2: (1) fix bug, introduced by v1 patch, reporeted by kernel-test-robot
v1: fix missing bug
ps: Because of many local commit, when using --base for format-patch,
there are too many prerequest-patch-id. I wonder if it will lead to other
problems. So now, I send this commit still without --base.
drivers/soc/sifive/sifive_l2_cache.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/soc/sifive/sifive_l2_cache.c b/drivers/soc/sifive/sifive_l2_cache.c
index 59640a1d0b28..e0e3d8b64c25 100644
--- a/drivers/soc/sifive/sifive_l2_cache.c
+++ b/drivers/soc/sifive/sifive_l2_cache.c
@@ -202,17 +202,22 @@ static int __init sifive_l2_init(void)
if (!np)
return -ENODEV;
- if (of_address_to_resource(np, 0, &res))
- return -ENODEV;
+ if (of_address_to_resource(np, 0, &res)) {
+ ret = -ENODEV;
+ goto out_put;
+ }
l2_base = ioremap(res.start, resource_size(&res));
- if (!l2_base)
- return -ENOMEM;
+ if (!l2_base) {
+ ret = -ENOMEM;
+ goto out_put;
+ }
intr_num = of_property_count_u32_elems(np, "interrupts");
if (!intr_num) {
pr_err("L2CACHE: no interrupts property\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_put;
}
for (i = 0; i < intr_num; i++) {
@@ -220,7 +225,8 @@ static int __init sifive_l2_init(void)
rc = request_irq(g_irq[i], l2_int_handler, 0, "l2_ecc", NULL);
if (rc) {
pr_err("L2CACHE: Could not request IRQ %d\n", g_irq[i]);
- return rc;
+ ret = rc;
+ goto out_put;
}
}
@@ -232,6 +238,10 @@ static int __init sifive_l2_init(void)
#ifdef CONFIG_DEBUG_FS
setup_sifive_debug();
#endif
- return 0;
+ ret = 0;
+
+out_put:
+ of_node_put(np);
+ return ret;
}
device_initcall(sifive_l2_init);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re:[PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put()
2022-06-16 4:49 [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put() Liang He
@ 2022-06-16 5:54 ` Liang He
2022-06-16 6:26 ` [PATCH " Conor.Dooley
2022-06-16 6:28 ` Conor.Dooley
1 sibling, 1 reply; 5+ messages in thread
From: Liang He @ 2022-06-16 5:54 UTC (permalink / raw)
To: palmer, paul.walmsley, aou; +Cc: linux-riscv, linux-kernel, kernel test robot
At 2022-06-16 12:49:15, "Liang He" <windhl@126.com> wrote:
>In sifive_l2_init(), of_find_matching_node() will return a node pointer
>with refcount incremented. We should use of_node_put() in each fail path
>or when it is not used anymore.
>
>Reported-by: kernel test robot <lkp@intel.com>
>
>Signed-off-by: Liang He <windhl@126.com>
>---
Sorry, please ignore this version as it still has a bug. I will have a strict check and compile the code before my next commit.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put()
2022-06-16 5:54 ` Liang He
@ 2022-06-16 6:26 ` Conor.Dooley
2022-06-16 6:52 ` Liang He
0 siblings, 1 reply; 5+ messages in thread
From: Conor.Dooley @ 2022-06-16 6:26 UTC (permalink / raw)
To: windhl, palmer, paul.walmsley, aou; +Cc: linux-riscv, linux-kernel, lkp
On 16/06/2022 06:54, Liang He wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> At 2022-06-16 12:49:15, "Liang He" <windhl@126.com> wrote:
>> In sifive_l2_init(), of_find_matching_node() will return a node pointer
>> with refcount incremented. We should use of_node_put() in each fail path
>> or when it is not used anymore.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>
>
> Sorry, please ignore this version as it still has a bug. I will have a strict check and compile the code before my next commit.
While you're at it - drop the Reported-by too.
You only need to include that if LKP found a problem with
a patch that's been applied already. If it's on something
in progress, just fix what it pointed out & resend.
Thanks,
Conor.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put()
2022-06-16 4:49 [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put() Liang He
2022-06-16 5:54 ` Liang He
@ 2022-06-16 6:28 ` Conor.Dooley
1 sibling, 0 replies; 5+ messages in thread
From: Conor.Dooley @ 2022-06-16 6:28 UTC (permalink / raw)
To: windhl, palmer, paul.walmsley, aou; +Cc: linux-riscv, linux-kernel, lkp
On 16/06/2022 05:49, Liang He wrote:
> [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put()
I figure you submitted a patch against hwmon & Guenter asked for
you to change the subject line? This is the hwmon style & the
brackets aren't needed in (most) other subsystems.
Thanks,
Conor.
> [You don't often get email from windhl@126.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> In sifive_l2_init(), of_find_matching_node() will return a node pointer
> with refcount incremented. We should use of_node_put() in each fail path
> or when it is not used anymore.
>
> Reported-by: kernel test robot <lkp@intel.com>
>
> Signed-off-by: Liang He <windhl@126.com>
> ---
> changelog:
>
> v2: (1) fix bug, introduced by v1 patch, reporeted by kernel-test-robot
> v1: fix missing bug
>
> ps: Because of many local commit, when using --base for format-patch,
> there are too many prerequest-patch-id. I wonder if it will lead to other
> problems. So now, I send this commit still without --base.
>
> drivers/soc/sifive/sifive_l2_cache.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/soc/sifive/sifive_l2_cache.c b/drivers/soc/sifive/sifive_l2_cache.c
> index 59640a1d0b28..e0e3d8b64c25 100644
> --- a/drivers/soc/sifive/sifive_l2_cache.c
> +++ b/drivers/soc/sifive/sifive_l2_cache.c
> @@ -202,17 +202,22 @@ static int __init sifive_l2_init(void)
> if (!np)
> return -ENODEV;
>
> - if (of_address_to_resource(np, 0, &res))
> - return -ENODEV;
> + if (of_address_to_resource(np, 0, &res)) {
> + ret = -ENODEV;
> + goto out_put;
> + }
>
> l2_base = ioremap(res.start, resource_size(&res));
> - if (!l2_base)
> - return -ENOMEM;
> + if (!l2_base) {
> + ret = -ENOMEM;
> + goto out_put;
> + }
>
> intr_num = of_property_count_u32_elems(np, "interrupts");
> if (!intr_num) {
> pr_err("L2CACHE: no interrupts property\n");
> - return -ENODEV;
> + ret = -ENODEV;
> + goto out_put;
> }
>
> for (i = 0; i < intr_num; i++) {
> @@ -220,7 +225,8 @@ static int __init sifive_l2_init(void)
> rc = request_irq(g_irq[i], l2_int_handler, 0, "l2_ecc", NULL);
> if (rc) {
> pr_err("L2CACHE: Could not request IRQ %d\n", g_irq[i]);
> - return rc;
> + ret = rc;
> + goto out_put;
> }
> }
>
> @@ -232,6 +238,10 @@ static int __init sifive_l2_init(void)
> #ifdef CONFIG_DEBUG_FS
> setup_sifive_debug();
> #endif
> - return 0;
> + ret = 0;
> +
> +out_put:
> + of_node_put(np);
> + return ret;
> }
> device_initcall(sifive_l2_init);
> --
> 2.25.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:Re: [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put()
2022-06-16 6:26 ` [PATCH " Conor.Dooley
@ 2022-06-16 6:52 ` Liang He
0 siblings, 0 replies; 5+ messages in thread
From: Liang He @ 2022-06-16 6:52 UTC (permalink / raw)
To: Conor.Dooley; +Cc: palmer, paul.walmsley, aou, linux-riscv, linux-kernel, lkp
At 2022-06-16 14:26:17, Conor.Dooley@microchip.com wrote:
>On 16/06/2022 06:54, Liang He wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>
>> At 2022-06-16 12:49:15, "Liang He" <windhl@126.com> wrote:
>>> In sifive_l2_init(), of_find_matching_node() will return a node pointer
>>> with refcount incremented. We should use of_node_put() in each fail path
>>> or when it is not used anymore.
>>>
>>> Reported-by: kernel test robot <lkp@intel.com>
>>>
>>> Signed-off-by: Liang He <windhl@126.com>
>>> ---
>>
>>
>> Sorry, please ignore this version as it still has a bug. I will have a strict check and compile the code before my next commit.
>
>While you're at it - drop the Reported-by too.
>You only need to include that if LKP found a problem with
>a patch that's been applied already. If it's on something
>in progress, just fix what it pointed out & resend.
>
>Thanks,
>Conor.
>
Thanks for all your help, Conor.
I will make a proper patch considering all things you suggested.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-16 6:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-16 4:49 [PATCH v2] soc: sifive: (sifive_l2_cache) Add missing of_node_put() Liang He
2022-06-16 5:54 ` Liang He
2022-06-16 6:26 ` [PATCH " Conor.Dooley
2022-06-16 6:52 ` Liang He
2022-06-16 6:28 ` Conor.Dooley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox