All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: tegra_alc5632: fix device_node refcounting
@ 2018-07-27 21:06 Alexey Khoroshilov
  2018-07-30  7:25 ` Marc Dietrich
  2018-07-30  8:23   ` Jon Hunter
  0 siblings, 2 replies; 4+ messages in thread
From: Alexey Khoroshilov @ 2018-07-27 21:06 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: Alexey Khoroshilov, linux-tegra, linux-kernel, ldv-project

tegra_alc5632_probe() increments reference count of device nodes
with of_parse_phandle(), but there is no code decrementing them
in the driver.

The patch adds of_node_put() to tegra_alc5632_remove() and
to error handling paths in the probe.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 sound/soc/tegra/tegra_alc5632.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index 5197d6b18cb6..98d87801d57a 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -190,14 +190,14 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev,
 			"Property 'nvidia,i2s-controller' missing or invalid\n");
 		ret = -EINVAL;
-		goto err;
+		goto err_put_codec_of_node;
 	}
 
 	tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_of_node;
 
 	ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
 	if (ret)
-		goto err;
+		goto err_put_cpu_of_node;
 
 	ret = snd_soc_register_card(card);
 	if (ret) {
@@ -210,6 +210,13 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
 
 err_fini_utils:
 	tegra_asoc_utils_fini(&alc5632->util_data);
+err_put_cpu_of_node:
+	of_node_put(tegra_alc5632_dai.cpu_of_node);
+	tegra_alc5632_dai.cpu_of_node = NULL;
+	tegra_alc5632_dai.platform_of_node = NULL;
+err_put_codec_of_node:
+	of_node_put(tegra_alc5632_dai.codec_of_node);
+	tegra_alc5632_dai.codec_of_node = NULL;
 err:
 	return ret;
 }
@@ -223,6 +230,12 @@ static int tegra_alc5632_remove(struct platform_device *pdev)
 
 	tegra_asoc_utils_fini(&machine->util_data);
 
+	of_node_put(tegra_alc5632_dai.cpu_of_node);
+	tegra_alc5632_dai.cpu_of_node = NULL;
+	tegra_alc5632_dai.platform_of_node = NULL;
+	of_node_put(tegra_alc5632_dai.codec_of_node);
+	tegra_alc5632_dai.codec_of_node = NULL;
+
 	return 0;
 }
 
-- 
2.7.4

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

* Re: [PATCH] ASoC: tegra_alc5632: fix device_node refcounting
  2018-07-27 21:06 [PATCH] ASoC: tegra_alc5632: fix device_node refcounting Alexey Khoroshilov
@ 2018-07-30  7:25 ` Marc Dietrich
  2018-07-30  8:23   ` Jon Hunter
  1 sibling, 0 replies; 4+ messages in thread
From: Marc Dietrich @ 2018-07-30  7:25 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	linux-tegra, linux-kernel, ldv-project

Hello Alexey,

AFAICT, this looks right. It seems that *most* of the machine 
drivers (not only tegra) forget to decrease the refcount. I'm wondering 
why you didn't sent a series patch to fix them all at once?

Reviewed-by: Marc Dietrich <marvin24@gmx.de>

Marc

On Sat, 28 Jul 2018, Alexey Khoroshilov wrote:

> tegra_alc5632_probe() increments reference count of device nodes
> with of_parse_phandle(), but there is no code decrementing them
> in the driver.
>
> The patch adds of_node_put() to tegra_alc5632_remove() and
> to error handling paths in the probe.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> sound/soc/tegra/tegra_alc5632.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
> index 5197d6b18cb6..98d87801d57a 100644
> --- a/sound/soc/tegra/tegra_alc5632.c
> +++ b/sound/soc/tegra/tegra_alc5632.c
> @@ -190,14 +190,14 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
> 		dev_err(&pdev->dev,
> 			"Property 'nvidia,i2s-controller' missing or invalid\n");
> 		ret = -EINVAL;
> -		goto err;
> +		goto err_put_codec_of_node;
> 	}
>
> 	tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_of_node;
>
> 	ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
> 	if (ret)
> -		goto err;
> +		goto err_put_cpu_of_node;
>
> 	ret = snd_soc_register_card(card);
> 	if (ret) {
> @@ -210,6 +210,13 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
>
> err_fini_utils:
> 	tegra_asoc_utils_fini(&alc5632->util_data);
> +err_put_cpu_of_node:
> +	of_node_put(tegra_alc5632_dai.cpu_of_node);
> +	tegra_alc5632_dai.cpu_of_node = NULL;
> +	tegra_alc5632_dai.platform_of_node = NULL;
> +err_put_codec_of_node:
> +	of_node_put(tegra_alc5632_dai.codec_of_node);
> +	tegra_alc5632_dai.codec_of_node = NULL;
> err:
> 	return ret;
> }
> @@ -223,6 +230,12 @@ static int tegra_alc5632_remove(struct platform_device *pdev)
>
> 	tegra_asoc_utils_fini(&machine->util_data);
>
> +	of_node_put(tegra_alc5632_dai.cpu_of_node);
> +	tegra_alc5632_dai.cpu_of_node = NULL;
> +	tegra_alc5632_dai.platform_of_node = NULL;
> +	of_node_put(tegra_alc5632_dai.codec_of_node);
> +	tegra_alc5632_dai.codec_of_node = NULL;
> +
> 	return 0;
> }
>
> -- 
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] ASoC: tegra_alc5632: fix device_node refcounting
  2018-07-27 21:06 [PATCH] ASoC: tegra_alc5632: fix device_node refcounting Alexey Khoroshilov
@ 2018-07-30  8:23   ` Jon Hunter
  2018-07-30  8:23   ` Jon Hunter
  1 sibling, 0 replies; 4+ messages in thread
From: Jon Hunter @ 2018-07-30  8:23 UTC (permalink / raw)
  To: Alexey Khoroshilov, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-tegra, linux-kernel, ldv-project


On 27/07/18 22:06, Alexey Khoroshilov wrote:
> tegra_alc5632_probe() increments reference count of device nodes
> with of_parse_phandle(), but there is no code decrementing them
> in the driver.
> 
> The patch adds of_node_put() to tegra_alc5632_remove() and
> to error handling paths in the probe.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  sound/soc/tegra/tegra_alc5632.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
> index 5197d6b18cb6..98d87801d57a 100644
> --- a/sound/soc/tegra/tegra_alc5632.c
> +++ b/sound/soc/tegra/tegra_alc5632.c
> @@ -190,14 +190,14 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev,
>  			"Property 'nvidia,i2s-controller' missing or invalid\n");
>  		ret = -EINVAL;
> -		goto err;
> +		goto err_put_codec_of_node;
>  	}
>  
>  	tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_of_node;
>  
>  	ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
>  	if (ret)
> -		goto err;
> +		goto err_put_cpu_of_node;
>  
>  	ret = snd_soc_register_card(card);
>  	if (ret) {
> @@ -210,6 +210,13 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
>  
>  err_fini_utils:
>  	tegra_asoc_utils_fini(&alc5632->util_data);
> +err_put_cpu_of_node:
> +	of_node_put(tegra_alc5632_dai.cpu_of_node);
> +	tegra_alc5632_dai.cpu_of_node = NULL;
> +	tegra_alc5632_dai.platform_of_node = NULL;
> +err_put_codec_of_node:
> +	of_node_put(tegra_alc5632_dai.codec_of_node);
> +	tegra_alc5632_dai.codec_of_node = NULL;
>  err:
>  	return ret;
>  }
> @@ -223,6 +230,12 @@ static int tegra_alc5632_remove(struct platform_device *pdev)
>  
>  	tegra_asoc_utils_fini(&machine->util_data);
>  
> +	of_node_put(tegra_alc5632_dai.cpu_of_node);
> +	tegra_alc5632_dai.cpu_of_node = NULL;
> +	tegra_alc5632_dai.platform_of_node = NULL;
> +	of_node_put(tegra_alc5632_dai.codec_of_node);
> +	tegra_alc5632_dai.codec_of_node = NULL;
> +
>  	return 0;
>  }

Thanks!

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

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

* Re: [PATCH] ASoC: tegra_alc5632: fix device_node refcounting
@ 2018-07-30  8:23   ` Jon Hunter
  0 siblings, 0 replies; 4+ messages in thread
From: Jon Hunter @ 2018-07-30  8:23 UTC (permalink / raw)
  To: Alexey Khoroshilov, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-tegra, linux-kernel, ldv-project


On 27/07/18 22:06, Alexey Khoroshilov wrote:
> tegra_alc5632_probe() increments reference count of device nodes
> with of_parse_phandle(), but there is no code decrementing them
> in the driver.
> 
> The patch adds of_node_put() to tegra_alc5632_remove() and
> to error handling paths in the probe.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  sound/soc/tegra/tegra_alc5632.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
> index 5197d6b18cb6..98d87801d57a 100644
> --- a/sound/soc/tegra/tegra_alc5632.c
> +++ b/sound/soc/tegra/tegra_alc5632.c
> @@ -190,14 +190,14 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev,
>  			"Property 'nvidia,i2s-controller' missing or invalid\n");
>  		ret = -EINVAL;
> -		goto err;
> +		goto err_put_codec_of_node;
>  	}
>  
>  	tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_of_node;
>  
>  	ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
>  	if (ret)
> -		goto err;
> +		goto err_put_cpu_of_node;
>  
>  	ret = snd_soc_register_card(card);
>  	if (ret) {
> @@ -210,6 +210,13 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
>  
>  err_fini_utils:
>  	tegra_asoc_utils_fini(&alc5632->util_data);
> +err_put_cpu_of_node:
> +	of_node_put(tegra_alc5632_dai.cpu_of_node);
> +	tegra_alc5632_dai.cpu_of_node = NULL;
> +	tegra_alc5632_dai.platform_of_node = NULL;
> +err_put_codec_of_node:
> +	of_node_put(tegra_alc5632_dai.codec_of_node);
> +	tegra_alc5632_dai.codec_of_node = NULL;
>  err:
>  	return ret;
>  }
> @@ -223,6 +230,12 @@ static int tegra_alc5632_remove(struct platform_device *pdev)
>  
>  	tegra_asoc_utils_fini(&machine->util_data);
>  
> +	of_node_put(tegra_alc5632_dai.cpu_of_node);
> +	tegra_alc5632_dai.cpu_of_node = NULL;
> +	tegra_alc5632_dai.platform_of_node = NULL;
> +	of_node_put(tegra_alc5632_dai.codec_of_node);
> +	tegra_alc5632_dai.codec_of_node = NULL;
> +
>  	return 0;
>  }

Thanks!

Acked-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

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

end of thread, other threads:[~2018-07-30  8:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 21:06 [PATCH] ASoC: tegra_alc5632: fix device_node refcounting Alexey Khoroshilov
2018-07-30  7:25 ` Marc Dietrich
2018-07-30  8:23 ` Jon Hunter
2018-07-30  8:23   ` Jon Hunter

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.