[alsa-devel] [PATCH 0/3] 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(-)
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.
Fixes: 2225a3e6af78 ("ALSA: ac97: add codecs devicetree binding") Signed-off-by: Takashi Iwai tiwai@suse.de ---
Only compile-tested. Please review carefully. Thanks!
sound/ac97/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c index 9f0c480489ef..9cbf6927abe9 100644 --- a/sound/ac97/bus.c +++ b/sound/ac97/bus.c @@ -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;
Takashi Iwai tiwai@suse.de writes:
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.
Fixes: 2225a3e6af78 ("ALSA: ac97: add codecs devicetree binding") Signed-off-by: Takashi Iwai tiwai@suse.de
Only compile-tested. Please review carefully. Thanks!
Hi Takashi,
Reviewed-by: Robert robert.jarzmik@free.fr
Cheers.
-- Robert
We forgot to unreference a node obtained via of_find_node_by_name() after its usage.
Signed-off-by: Takashi Iwai tiwai@suse.de ---
Only compile-tested. Please review carefully. Thanks!
sound/aoa/core/gpio-feature.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/aoa/core/gpio-feature.c b/sound/aoa/core/gpio-feature.c index 65557421fe0b..c3ff721e4660 100644 --- a/sound/aoa/core/gpio-feature.c +++ b/sound/aoa/core/gpio-feature.c @@ -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;
On Tue, 2019-02-19 at 16:31 +0100, Takashi Iwai wrote:
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?
Only compile-tested. Please review carefully. Thanks!
Yes, looks right
Reviewed-by: Johannes Berg johannes@sipsolutions.net
I still have, but no longer run, the machine that uses this driver ... anyone need a Powermac G5 quad? ;-)
johannes
On Tue, 19 Feb 2019 16:50:00 +0100, Johannes Berg wrote:
On Tue, 2019-02-19 at 16:31 +0100, Takashi Iwai wrote:
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 :)
Only compile-tested. Please review carefully. Thanks!
Yes, looks right
Reviewed-by: Johannes Berg johannes@sipsolutions.net
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
We 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.
Signed-off-by: Takashi Iwai tiwai@suse.de ---
Only compile-tested. Please review carefully. Thanks!
sound/ppc/tumbler.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 6d7ffffcce95..78e5798ae967 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -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; } }
participants (3)
-
Johannes Berg
-
Robert Jarzmik
-
Takashi Iwai