* [PATCH 1/3] crypto: nx: Hold the reference returned by of_find_compatible_node
@ 2022-07-01 11:26 Liang He
2022-07-01 11:26 ` [PATCH 2/3] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init() Liang He
2022-07-01 11:26 ` [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation Liang He
0 siblings, 2 replies; 5+ messages in thread
From: Liang He @ 2022-07-01 11:26 UTC (permalink / raw)
To: tony, linux, linux-omap, windhl
In nx842_pseries_init(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put to keep
refcount balance.
Signed-off-by: Liang He <windhl@126.com>
---
drivers/crypto/nx/nx-common-pseries.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
index 7584a34ba88c..3ea334b7f820 100644
--- a/drivers/crypto/nx/nx-common-pseries.c
+++ b/drivers/crypto/nx/nx-common-pseries.c
@@ -1208,10 +1208,13 @@ static struct vio_driver nx842_vio_driver = {
static int __init nx842_pseries_init(void)
{
struct nx842_devdata *new_devdata;
+ struct device_node *np;
int ret;
- if (!of_find_compatible_node(NULL, NULL, "ibm,compression"))
+ np = of_find_compatible_node(NULL, NULL, "ibm,compression");
+ if (!np)
return -ENODEV;
+ of_node_put(np);
RCU_INIT_POINTER(devdata, NULL);
new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init()
2022-07-01 11:26 [PATCH 1/3] crypto: nx: Hold the reference returned by of_find_compatible_node Liang He
@ 2022-07-01 11:26 ` Liang He
2022-07-01 11:26 ` [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation Liang He
1 sibling, 0 replies; 5+ messages in thread
From: Liang He @ 2022-07-01 11:26 UTC (permalink / raw)
To: tony, linux, linux-omap, windhl
To keep refcount balance, we need to call of_node_put() for the
reference 'state_node' returned by of_parse_phandle() in fail
path or when it is not used anymore.
Signed-off-by: Liang He <windhl@126.com>
---
arch/arm/mach-omap2/pm33xx-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/pm33xx-core.c b/arch/arm/mach-omap2/pm33xx-core.c
index bf0d25fd2cea..58b98a17746c 100644
--- a/arch/arm/mach-omap2/pm33xx-core.c
+++ b/arch/arm/mach-omap2/pm33xx-core.c
@@ -393,12 +393,15 @@ static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)
if (!state_node)
break;
- if (!of_device_is_available(state_node))
+ if (!of_device_is_available(state_node)) {
+ of_node_put(state_node);
continue;
+ }
if (i == CPUIDLE_STATE_MAX) {
pr_warn("%s: cpuidle states reached max possible\n",
__func__);
+ of_node_put(state_node);
break;
}
@@ -408,6 +411,7 @@ static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)
states[state_count].wfi_flags |= WFI_FLAG_WAKE_M3 |
WFI_FLAG_FLUSH_CACHE;
+ of_node_put(state_node);
state_count++;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation
2022-07-01 11:26 [PATCH 1/3] crypto: nx: Hold the reference returned by of_find_compatible_node Liang He
2022-07-01 11:26 ` [PATCH 2/3] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init() Liang He
@ 2022-07-01 11:26 ` Liang He
2022-07-04 7:47 ` Tony Lindgren
1 sibling, 1 reply; 5+ messages in thread
From: Liang He @ 2022-07-01 11:26 UTC (permalink / raw)
To: tony, linux, linux-omap, windhl
In omap2_prm_base_init(), for_each_matching_node_and_match() can
automatically increase and decrease the refcounting. However, a
new reference is escaped out into 'data->np', so we need to use
of_node_put() for the old reference and use of_node_get() for the
new one.
Signed-off-by: Liang He <windhl@126.com>
---
arch/arm/mach-omap2/prm_common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index fb2d48cfe756..bed151e3f165 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -764,7 +764,8 @@ int __init omap2_prm_base_init(void)
prm_base.pa = res.start + data->offset;
}
- data->np = np;
+ of_node_put(data->np);
+ data->np = of_node_get(np);
if (data->init)
data->init(data);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation
2022-07-01 11:26 ` [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation Liang He
@ 2022-07-04 7:47 ` Tony Lindgren
2022-07-04 7:56 ` Liang He
0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2022-07-04 7:47 UTC (permalink / raw)
To: Liang He; +Cc: linux, linux-omap
* Liang He <windhl@126.com> [220701 14:22]:
> In omap2_prm_base_init(), for_each_matching_node_and_match() can
> automatically increase and decrease the refcounting. However, a
> new reference is escaped out into 'data->np', so we need to use
> of_node_put() for the old reference and use of_node_get() for the
> new one.
>
> Signed-off-by: Liang He <windhl@126.com>
> ---
> arch/arm/mach-omap2/prm_common.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
> index fb2d48cfe756..bed151e3f165 100644
> --- a/arch/arm/mach-omap2/prm_common.c
> +++ b/arch/arm/mach-omap2/prm_common.c
> @@ -764,7 +764,8 @@ int __init omap2_prm_base_init(void)
> prm_base.pa = res.start + data->offset;
> }
>
> - data->np = np;
> + of_node_put(data->np);
> + data->np = of_node_get(np);
>
> if (data->init)
> data->init(data);
Hmm so I don't get how this improves things? Don't we enable with
the same refcounting?
Regards,
Tony
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:Re: [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation
2022-07-04 7:47 ` Tony Lindgren
@ 2022-07-04 7:56 ` Liang He
0 siblings, 0 replies; 5+ messages in thread
From: Liang He @ 2022-07-04 7:56 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux, linux-omap
At 2022-07-04 15:47:01, "Tony Lindgren" <tony@atomide.com> wrote:
>* Liang He <windhl@126.com> [220701 14:22]:
>> In omap2_prm_base_init(), for_each_matching_node_and_match() can
>> automatically increase and decrease the refcounting. However, a
>> new reference is escaped out into 'data->np', so we need to use
>> of_node_put() for the old reference and use of_node_get() for the
>> new one.
>>
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>> arch/arm/mach-omap2/prm_common.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
>> index fb2d48cfe756..bed151e3f165 100644
>> --- a/arch/arm/mach-omap2/prm_common.c
>> +++ b/arch/arm/mach-omap2/prm_common.c
>> @@ -764,7 +764,8 @@ int __init omap2_prm_base_init(void)
>> prm_base.pa = res.start + data->offset;
>> }
>>
>> - data->np = np;
>> + of_node_put(data->np);
>> + data->np = of_node_get(np);
>>
>> if (data->init)
>> data->init(data);
>
>Hmm so I don't get how this improves things? Don't we enable with
>the same refcounting?
>
>Regards,
>
>Tony
Hi, Tony.
Thanks very much for reviewing this patch.
I try to explain as following:
First, there is an old reference (pointer) pointing to device_node A and stored in data->np.
Then, in the for_each_xxx iteration, 'np' is a new reference (pointer) pointing to device_node B.
After 'data->np = np' is done, the old reference is destroyed and its refcount should be decreased.
Similarly, a new reference to devce_node B is created in 'data->np', so its refcount should be increased.
Sorry if my understanding is wrong or if I do not catch your point.
Thans again,
Liang
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-04 7:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-01 11:26 [PATCH 1/3] crypto: nx: Hold the reference returned by of_find_compatible_node Liang He
2022-07-01 11:26 ` [PATCH 2/3] arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init() Liang He
2022-07-01 11:26 ` [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation Liang He
2022-07-04 7:47 ` Tony Lindgren
2022-07-04 7:56 ` Liang He
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.