diff mbox series

[1/6] ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt()

Message ID 20190219154652.13644-2-tiwai@suse.de (mailing list archive)
State Accepted
Commit 2757970f6d0d0a112247600b23d38c0c728ceeb3
Headers show
Series ASoC: Fix of-node refcount unbalance | expand

Commit Message

Takashi Iwai Feb. 19, 2019, 3:46 p.m. UTC
The node obtained from of_find_node_by_path() has to be unreferenced
after the use, but we forgot it for the root node.

Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support")
Cc: Timur Tabi <timur@kernel.org>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---

Only compile-tested.  Please review carefully.  Thanks!

 sound/soc/fsl/fsl_ssi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Nicolin Chen Feb. 20, 2019, 5:29 a.m. UTC | #1
On Tue, Feb 19, 2019 at 04:46:47PM +0100, Takashi Iwai wrote:
> The node obtained from of_find_node_by_path() has to be unreferenced
> after the use, but we forgot it for the root node.
> 
> Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support")
> Cc: Timur Tabi <timur@kernel.org>
> Cc: Nicolin Chen <nicoleotsuka@gmail.com>

Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>

> Cc: Xiubo Li <Xiubo.Lee@gmail.com>
> Cc: Fabio Estevam <festevam@gmail.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> 
> Only compile-tested.  Please review carefully.  Thanks!

Ran a boot test by removing the if-condition. It'd be fine.

Thank you
Nicolin
 
>  sound/soc/fsl/fsl_ssi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
> index 0a648229e643..09b2967befd9 100644
> --- a/sound/soc/fsl/fsl_ssi.c
> +++ b/sound/soc/fsl/fsl_ssi.c
> @@ -1439,8 +1439,10 @@ static int fsl_ssi_probe_from_dt(struct fsl_ssi *ssi)
>  	 * different name to register the device.
>  	 */
>  	if (!ssi->card_name[0] && of_get_property(np, "codec-handle", NULL)) {
> -		sprop = of_get_property(of_find_node_by_path("/"),
> -					"compatible", NULL);
> +		struct device_node *root = of_find_node_by_path("/");
> +
> +		sprop = of_get_property(root, "compatible", NULL);
> +		of_node_put(root);
>  		/* Strip "fsl," in the compatible name if applicable */
>  		p = strrchr(sprop, ',');
>  		if (p)
> -- 
> 2.16.4
>
diff mbox series

Patch

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 0a648229e643..09b2967befd9 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1439,8 +1439,10 @@  static int fsl_ssi_probe_from_dt(struct fsl_ssi *ssi)
 	 * different name to register the device.
 	 */
 	if (!ssi->card_name[0] && of_get_property(np, "codec-handle", NULL)) {
-		sprop = of_get_property(of_find_node_by_path("/"),
-					"compatible", NULL);
+		struct device_node *root = of_find_node_by_path("/");
+
+		sprop = of_get_property(root, "compatible", NULL);
+		of_node_put(root);
 		/* Strip "fsl," in the compatible name if applicable */
 		p = strrchr(sprop, ',');
 		if (p)