ALSA: Fix of-node refcount unbalance
Subsystems (2)
cover ALSA: Fix of-node refcount unbalance
Hi,
here is a few patches to address the unbalanced OF-node refcount on powerpc and ac97 driver code. Another patchset for ASoC will follow later.
Takashi
===
Takashi Iwai (3):
ALSA: ac97: Fix of-node refcount unbalance
ALSA: aoa: Fix of-node refcount unbalance
ALSA: ppc: Fix of-node refcount unbalance
sound/ac97/bus.c | 2 +- sound/aoa/core/gpio-feature.c | 1 + sound/ppc/tumbler.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.16.4
PATCH 1/3 ALSA: ac97: Fix of-node refcount unbalance
ac97_of_get_child_device() take the refcount of the node explicitly via of_node_get(), but this leads to an unbalance. The for_each_child_of_node() loop itself takes the refcount for each iteration node, hence you don't need to take the extra refcount again.
---
Only compile-tested. Please review carefully. Thanks!
sound/ac97/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/ac97/bus.c +1 -1
@@ -84,7 +84,7 @@ ac97_of_get_child_device(struct ac97_controller *ac97_ctrl, int idx,if ((idx !=of_property_read_u32 (node,"reg" , ®)) || !of_device_is_compatible (node, compat))continue ; -return of_node_get (node); +return node; }return NULL ;
Signature · 1 line
2.16.4
Re: [PATCH 1/3] ALSA: ac97: Fix of-node refcount unbalance
Quoted 11 lines · Takashi Iwai
ac97_of_get_child_device()take the refcount of the node explicitly viaof_node_get(), but this leads to an unbalance. Thefor_each_child_of_node()loop itself takes the refcount for each iteration node, hence you don't need to take the extra refcount again.Fixes 2225a3e6af78 ("ALSA: ac97: add codecs devicetree binding")Signed-off-by Takashi Iwai <[email protected]>---
Only compile-tested. Please review carefully. Thanks!
Hi Takashi,
Cheers.
--
Robert
PATCH 2/3 ALSA: aoa: Fix of-node refcount unbalance
In reply to Takashi IwaiWe forgot to unreference a node obtained via of_find_node_by_name() after its usage.
---
Only compile-tested. Please review carefully. Thanks!
sound/aoa/core/gpio-feature.c | 1 + 1 file changed, 1 insertion(+)
sound/aoa/core/gpio-feature.c +1 -0
@@ -82,6 +82,7 @@ static struct device_node *get_gpio(char *name,if (altname && (strcmp (audio_gpio, altname) ==0 ))break ; } +of_node_put (gpio);/* still not found, assume not there */ if (!np)return NULL ;
Signature · 1 line
2.16.4
Re: [PATCH 2/3] ALSA: aoa: Fix of-node refcount unbalance
Quoted 2 lines · Takashi Iwai
We forgot to unreference a node obtained via
of_find_node_by_name()after its usage.
How did you find this now?! Though I guess something like smatch could find it, or even coccinelle?
Quoted 1 line
Only compile-tested. Please review carefully. Thanks!
Yes, looks right
I still have, but no longer run, the machine that uses this driver ... anyone need a Powermac G5 quad? ;-)
johannes
Re: [PATCH 2/3] ALSA: aoa: Fix of-node refcount unbalance
Quoted 7 lines · Johannes Berg
Quoted 2 lines · Takashi Iwai
We forgot to unreference a node obtained via
of_find_node_by_name()after its usage.How did you find this now?! Though I guess something like smatch could find it, or even coccinelle?
I'm old-fashioned, just did manual reviews casually after the discussion about the recent regression regarding OF node refcount in an ASoC driver :)
A coccinelle or such would be smarter, yeah :)
Quoted 8 lines
Quoted 1 line
Only compile-tested. Please review carefully. Thanks!
Yes, looks right
Reviewed-by Johannes Berg <[email protected]>I still have, but no longer run, the machine that uses this driver ... anyone need a Powermac G5 quad? ;-)
Let's seek for museums :)
thanks,
Takashi
PATCH 3/3 ALSA: ppc: Fix of-node refcount unbalance
In reply to Takashi IwaiWe forgot to unreference the node when aborting from the loop of for_each_child_of_node() in snd_pmac_tumbler_init(). This leads to unbalanced node refcount. Fix it by adding the missing of_node_put() call.
---
Only compile-tested. Please review carefully. Thanks!
sound/ppc/tumbler.c | 1 + 1 file changed, 1 insertion(+)
sound/ppc/tumbler.c +1 -0
@@ -1371,6 +1371,7 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) mix->anded_reset =1 ;if (of_get_property (np,"layout-id" ,NULL )) mix->reset_on_sleep =0 ; +of_node_put (np);break ; } }
Signature · 1 line
2.16.4