crypto: nx: Hold the reference returned by of_find_compatible_node
Subsystems (7)
PATCH 1/3 crypto: nx: Hold the reference returned by of_find_compatible_node
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.
--- drivers/crypto/nx/nx-common-pseries.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/crypto/nx/nx-common-pseries.c +4 -1
@@ -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 );
Signature · 1 line
2.25.1
PATCH 2/3 arm: omap2: pm33xx-core: Fix missing of_node_put() in amx3_idle_init()
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.
--- arch/arm/mach-omap2/pm33xx-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/pm33xx-core.c +5 -1
@@ -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++; }
Signature · 1 line
2.25.1
PATCH 3/3 arm: omap2: prm_common: Add the refcount for new reference creation
In reply to Liang HeIn 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.
--- arch/arm/mach-omap2/prm_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/prm_common.c +2 -1
@@ -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);
Signature · 1 line
2.25.1
Tony Lindgren
maintainerRe: [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation
Quoted 16 lines · Liang He
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 useof_node_put()for the old reference and useof_node_get()for the new one.Signed-off-by Liang He <[email protected]>--- arch/arm/mach-omap2/prm_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm/mach-omap2/prm_common.c +0
-0
arch/arm/mach-omap2/prm_common.c int __init omap2_prm_base_init(void) · line 771
Quoted 9 lines
arch/arm/mach-omap2/prm_common.c +2
-1@@ -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
Re:Re: [PATCH 3/3] arm: omap2: prm_common: Add the refcount for new reference creation
Quoted 30 lines · Tony Lindgren
Quoted 16 lines · Liang He
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 useof_node_put()for the old reference and useof_node_get()for the new one.Signed-off-by Liang He <[email protected]>--- arch/arm/mach-omap2/prm_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm/mach-omap2/prm_common.c +0
-0arch/arm/mach-omap2/prm_common.c int __init omap2_prm_base_init(void) · line 771
Quoted 9 lines
arch/arm/mach-omap2/prm_common.c +2
-1@@ -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?
Quoted 3 lines
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