Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ASoC: simple-card-utils fixups
@ 2025-02-26 23:30 Kuninori Morimoto
  2025-02-26 23:30 ` [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai() Kuninori Morimoto
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2025-02-26 23:30 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound


Hi Mark

linus/master includes my patch (419d1918105e) which uses __free() in
simple-card-utils. But because of it, it has of_node_put() count underrun
issue. [1/2] is needed for it.

[2/2] is just cleanup patch on top of it.

v1 -> v2
	- Separate patches

Kuninori Morimoto (2):
  ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai()
  ASoC: simple-card-utils: fixup dlc->xxx handling for error case

 sound/soc/generic/simple-card-utils.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

-- 
2.43.0





Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai()
  2025-02-26 23:30 [PATCH v2 0/2] ASoC: simple-card-utils fixups Kuninori Morimoto
@ 2025-02-26 23:30 ` Kuninori Morimoto
  2025-02-27 11:55   ` Mark Brown
  2025-02-26 23:30 ` [PATCH v2 2/2] ASoC: simple-card-utils: fixup dlc->xxx handling for error case Kuninori Morimoto
  2025-03-14 15:52 ` [PATCH v2 0/2] ASoC: simple-card-utils fixups Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2025-02-26 23:30 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

commit 419d1918105e ("ASoC: simple-card-utils: use __free(device_node) for
device node") uses __free(device_node) for dlc->of_node, but we need to
keep it while driver is in use.

Don't use __free(device_node) in graph_util_parse_dai().

Fixes: 419d1918105e ("ASoC: simple-card-utils: use __free(device_node) for device node")
Reported-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn>
Reported-by: Detlev Casanova <detlev.casanova@collabora.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn>
Tested-by: Detlev Casanova <detlev.casanova@collabora.com>
---
 sound/soc/generic/simple-card-utils.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 51e0e434514d..79fdd57a470c 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -1102,6 +1102,7 @@ static int graph_get_dai_id(struct device_node *ep)
 int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,
 			 struct snd_soc_dai_link_component *dlc, int *is_single_link)
 {
+	struct device_node *node;
 	struct device *dev = simple_priv_to_dev(priv);
 	struct of_phandle_args args = {};
 	struct snd_soc_dai *dai;
@@ -1110,7 +1111,7 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,
 	if (!ep)
 		return 0;
 
-	struct device_node *node __free(device_node) = of_graph_get_port_parent(ep);
+	node = of_graph_get_port_parent(ep);
 
 	/*
 	 * Try to find from DAI node
@@ -1153,8 +1154,10 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,
 	 *    if he unbinded CPU or Codec.
 	 */
 	ret = snd_soc_get_dlc(&args, dlc);
-	if (ret < 0)
+	if (ret < 0) {
+		of_node_put(node);
 		goto end;
+	}
 
 parse_dai_end:
 	if (is_single_link)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] ASoC: simple-card-utils: fixup dlc->xxx handling for error case
  2025-02-26 23:30 [PATCH v2 0/2] ASoC: simple-card-utils fixups Kuninori Morimoto
  2025-02-26 23:30 ` [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai() Kuninori Morimoto
@ 2025-02-26 23:30 ` Kuninori Morimoto
  2025-03-14 15:52 ` [PATCH v2 0/2] ASoC: simple-card-utils fixups Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2025-02-26 23:30 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

Current graph_util_parse_dai() has 2 issue for dlc->xxx handling.

1) dlc->xxx might be filled if snd_soc_get_dai_via_args() (A) works.
   In such case it will fill dlc->xxx first (B), and detect error
   after that (C). We need to fill dlc->xxx in success case only.

(A)	dai = snd_soc_get_dai_via_args(&args);
	if (dai) {
		ret = -ENOMEM;
 ^		dlc->of_node  = ...
(B)		dlc->dai_name = ...
 v		dlc->dai_args = ...
(C)		if (!dlc->dai_args)
			goto end;
		...
	}

2) graph_util_parse_dai() itself has 2 patterns (X)(Y) to fill dlc->xxx.
   Both case, we need to call of_node_put(node) in error case, but we
   are calling it only in (Y) case.

	int graph_util_parse_dai(...)
	{
		...
		dai = snd_soc_get_dai_via_args(&args);
		if (dai) {
			...
 ^			dlc->of_node  = ...
(X)			dlc->dai_name = ...
 v			dlc->dai_args = ...
			...
		}
		...
(Y)		ret = snd_soc_get_dlc(&args, dlc);
		if (ret < 0) {
			of_node_put(node);
			...
		}
		...
	}

This patch fixup both case. Make it easy to understand, update
lavel "end" to "err", too.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card-utils.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 79fdd57a470c..692bafca55af 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -1119,12 +1119,16 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,
 	args.np = ep;
 	dai = snd_soc_get_dai_via_args(&args);
 	if (dai) {
+		const char *dai_name = snd_soc_dai_name_get(dai);
+		const struct of_phandle_args *dai_args = snd_soc_copy_dai_args(dev, &args);
+
 		ret = -ENOMEM;
+		if (!dai_args)
+			goto err;
+
 		dlc->of_node  = node;
-		dlc->dai_name = snd_soc_dai_name_get(dai);
-		dlc->dai_args = snd_soc_copy_dai_args(dev, &args);
-		if (!dlc->dai_args)
-			goto end;
+		dlc->dai_name = dai_name;
+		dlc->dai_args = dai_args;
 
 		goto parse_dai_end;
 	}
@@ -1154,16 +1158,17 @@ int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep,
 	 *    if he unbinded CPU or Codec.
 	 */
 	ret = snd_soc_get_dlc(&args, dlc);
-	if (ret < 0) {
-		of_node_put(node);
-		goto end;
-	}
+	if (ret < 0)
+		goto err;
 
 parse_dai_end:
 	if (is_single_link)
 		*is_single_link = of_graph_get_endpoint_count(node) == 1;
 	ret = 0;
-end:
+err:
+	if (ret < 0)
+		of_node_put(node);
+
 	return simple_ret(priv, ret);
 }
 EXPORT_SYMBOL_GPL(graph_util_parse_dai);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai()
  2025-02-26 23:30 ` [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai() Kuninori Morimoto
@ 2025-02-27 11:55   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-02-27 11:55 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: linux-sound

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]

On Wed, Feb 26, 2025 at 11:30:49PM +0000, Kuninori Morimoto wrote:
> commit 419d1918105e ("ASoC: simple-card-utils: use __free(device_node) for
> device node") uses __free(device_node) for dlc->of_node, but we need to
> keep it while driver is in use.
> 
> Don't use __free(device_node) in graph_util_parse_dai().
> 
> Fixes: 419d1918105e ("ASoC: simple-card-utils: use __free(device_node) for device node")

This isn't applying against my 6.14 branch, it's got a dependency on
some of the changes in -next unfortunately.  Could you rebase onto
for-6.14 please?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] ASoC: simple-card-utils fixups
  2025-02-26 23:30 [PATCH v2 0/2] ASoC: simple-card-utils fixups Kuninori Morimoto
  2025-02-26 23:30 ` [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai() Kuninori Morimoto
  2025-02-26 23:30 ` [PATCH v2 2/2] ASoC: simple-card-utils: fixup dlc->xxx handling for error case Kuninori Morimoto
@ 2025-03-14 15:52 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-03-14 15:52 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: linux-sound

On Wed, 26 Feb 2025 23:30:36 +0000, Kuninori Morimoto wrote:
> linus/master includes my patch (419d1918105e) which uses __free() in
> simple-card-utils. But because of it, it has of_node_put() count underrun
> issue. [1/2] is needed for it.
> 
> [2/2] is just cleanup patch on top of it.
> 
> v1 -> v2
> 	- Separate patches
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai()
      commit: de74ec718e0788e1998eb7289ad07970e27cae27
[2/2] ASoC: simple-card-utils: fixup dlc->xxx handling for error case
      (no commit info)

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-14 15:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 23:30 [PATCH v2 0/2] ASoC: simple-card-utils fixups Kuninori Morimoto
2025-02-26 23:30 ` [PATCH v2 1/2] ASoC: simple-card-utils: Don't use __free(device_node) at graph_util_parse_dai() Kuninori Morimoto
2025-02-27 11:55   ` Mark Brown
2025-02-26 23:30 ` [PATCH v2 2/2] ASoC: simple-card-utils: fixup dlc->xxx handling for error case Kuninori Morimoto
2025-03-14 15:52 ` [PATCH v2 0/2] ASoC: simple-card-utils fixups Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox