* [PATCH 1/1] arm: devtree: fix missing device_node cleanup
@ 2024-07-12 9:44 Vincenzo Mezzela
2024-07-12 9:47 ` Javier Carrasco
0 siblings, 1 reply; 3+ messages in thread
From: Vincenzo Mezzela @ 2024-07-12 9:44 UTC (permalink / raw)
To: linux, robh, rmk+kernel
Cc: linux-arm-kernel, linux-kernel, javier.carrasco.cruz, skhan,
Vincenzo Mezzela
Device node `cpus` is allocated but never released using `of_node_put`.
This patch introduces the __free attribute for `cpus` device_node that
automatically handle the cleanup of the resource by adding a call to
`of_node_put` at the end of the current scope. This enhancement aims to
mitigate memory management issues associated with forgetting to release
the resources.
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@gmail.com>
---
arch/arm/kernel/devtree.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index fdb74e64206a..223d66a5fff3 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -70,14 +70,14 @@ void __init arm_dt_init_cpu_maps(void)
* contain a list of MPIDR[23:0] values where MPIDR[31:24] must
* read as 0.
*/
- struct device_node *cpu, *cpus;
int found_method = 0;
u32 i, j, cpuidx = 1;
u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
bool bootcpu_valid = false;
- cpus = of_find_node_by_path("/cpus");
+ struct device_node *cpu;
+ struct device_node *cpus __free(device_node) = of_find_node_by_path("/cpus");
if (!cpus)
return;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] arm: devtree: fix missing device_node cleanup
2024-07-12 9:44 [PATCH 1/1] arm: devtree: fix missing device_node cleanup Vincenzo Mezzela
@ 2024-07-12 9:47 ` Javier Carrasco
2024-07-29 10:18 ` vincenzo mezzela
0 siblings, 1 reply; 3+ messages in thread
From: Javier Carrasco @ 2024-07-12 9:47 UTC (permalink / raw)
To: Vincenzo Mezzela, linux, robh, rmk+kernel
Cc: linux-arm-kernel, linux-kernel, skhan
On 12/07/2024 11:44, Vincenzo Mezzela wrote:
> Device node `cpus` is allocated but never released using `of_node_put`.
>
> This patch introduces the __free attribute for `cpus` device_node that
> automatically handle the cleanup of the resource by adding a call to
> `of_node_put` at the end of the current scope. This enhancement aims to
> mitigate memory management issues associated with forgetting to release
> the resources.
>
> Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@gmail.com>
> ---
> arch/arm/kernel/devtree.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> index fdb74e64206a..223d66a5fff3 100644
> --- a/arch/arm/kernel/devtree.c
> +++ b/arch/arm/kernel/devtree.c
> @@ -70,14 +70,14 @@ void __init arm_dt_init_cpu_maps(void)
> * contain a list of MPIDR[23:0] values where MPIDR[31:24] must
> * read as 0.
> */
> - struct device_node *cpu, *cpus;
> int found_method = 0;
> u32 i, j, cpuidx = 1;
> u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
>
> u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
> bool bootcpu_valid = false;
> - cpus = of_find_node_by_path("/cpus");
> + struct device_node *cpu;
> + struct device_node *cpus __free(device_node) = of_find_node_by_path("/cpus");
>
> if (!cpus)
> return;
Hello Vincenzo,
If this is a fix, please provide the Fixes: tag as well as Cc: for
stable if it applies.
Best regards,
Javier Carrasco
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] arm: devtree: fix missing device_node cleanup
2024-07-12 9:47 ` Javier Carrasco
@ 2024-07-29 10:18 ` vincenzo mezzela
0 siblings, 0 replies; 3+ messages in thread
From: vincenzo mezzela @ 2024-07-29 10:18 UTC (permalink / raw)
To: Javier Carrasco, linux, robh, rmk+kernel
Cc: linux-arm-kernel, linux-kernel, skhan, stable
On 7/12/24 11:47, Javier Carrasco wrote:
> On 12/07/2024 11:44, Vincenzo Mezzela wrote:
>> Device node `cpus` is allocated but never released using `of_node_put`.
>>
>> This patch introduces the __free attribute for `cpus` device_node that
>> automatically handle the cleanup of the resource by adding a call to
>> `of_node_put` at the end of the current scope. This enhancement aims to
>> mitigate memory management issues associated with forgetting to release
>> the resources.
>>
>> Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@gmail.com>
>> ---
>> arch/arm/kernel/devtree.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
>> index fdb74e64206a..223d66a5fff3 100644
>> --- a/arch/arm/kernel/devtree.c
>> +++ b/arch/arm/kernel/devtree.c
>> @@ -70,14 +70,14 @@ void __init arm_dt_init_cpu_maps(void)
>> * contain a list of MPIDR[23:0] values where MPIDR[31:24] must
>> * read as 0.
>> */
>> - struct device_node *cpu, *cpus;
>> int found_method = 0;
>> u32 i, j, cpuidx = 1;
>> u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
>>
>> u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
>> bool bootcpu_valid = false;
>> - cpus = of_find_node_by_path("/cpus");
>> + struct device_node *cpu;
>> + struct device_node *cpus __free(device_node) = of_find_node_by_path("/cpus");
>>
>> if (!cpus)
>> return;
> Hello Vincenzo,
>
> If this is a fix, please provide the Fixes: tag as well as Cc: for
> stable if it applies.
>
> Best regards, Javier Carrasco
Sure, will do. :)
Best regards,
Vincenzo
Fixes: a0ae02405076a ("ARM: kernel: add device tree init map function")
Cc: stable@vger.kernel.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-29 10:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 9:44 [PATCH 1/1] arm: devtree: fix missing device_node cleanup Vincenzo Mezzela
2024-07-12 9:47 ` Javier Carrasco
2024-07-29 10:18 ` vincenzo mezzela
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).