mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	ASoC: tegra: fix device_node refcounting
tegra_rt5677_probe() gets a couple of device nodes with of_parse_phandle(), but there is no release of them. The patch adds the release to tegra_rt5677_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> Reviewed-by: Nicholas Mc Guire <der.herr@hofr.at> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
		
							parent
							
								
									a4519526eb
								
							
						
					
					
						commit
						7c5dfd5496
					
				
					 1 changed files with 15 additions and 2 deletions
				
			
		| 
						 | 
					@ -264,13 +264,13 @@ static int tegra_rt5677_probe(struct platform_device *pdev)
 | 
				
			||||||
		dev_err(&pdev->dev,
 | 
							dev_err(&pdev->dev,
 | 
				
			||||||
			"Property 'nvidia,i2s-controller' missing or invalid\n");
 | 
								"Property 'nvidia,i2s-controller' missing or invalid\n");
 | 
				
			||||||
		ret = -EINVAL;
 | 
							ret = -EINVAL;
 | 
				
			||||||
		goto err;
 | 
							goto err_put_codec_of_node;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	tegra_rt5677_dai.platform_of_node = tegra_rt5677_dai.cpu_of_node;
 | 
						tegra_rt5677_dai.platform_of_node = tegra_rt5677_dai.cpu_of_node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
 | 
						ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		goto err;
 | 
							goto err_put_cpu_of_node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = snd_soc_register_card(card);
 | 
						ret = snd_soc_register_card(card);
 | 
				
			||||||
	if (ret) {
 | 
						if (ret) {
 | 
				
			||||||
| 
						 | 
					@ -283,6 +283,13 @@ static int tegra_rt5677_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
err_fini_utils:
 | 
					err_fini_utils:
 | 
				
			||||||
	tegra_asoc_utils_fini(&machine->util_data);
 | 
						tegra_asoc_utils_fini(&machine->util_data);
 | 
				
			||||||
 | 
					err_put_cpu_of_node:
 | 
				
			||||||
 | 
						of_node_put(tegra_rt5677_dai.cpu_of_node);
 | 
				
			||||||
 | 
						tegra_rt5677_dai.cpu_of_node = NULL;
 | 
				
			||||||
 | 
						tegra_rt5677_dai.platform_of_node = NULL;
 | 
				
			||||||
 | 
					err_put_codec_of_node:
 | 
				
			||||||
 | 
						of_node_put(tegra_rt5677_dai.codec_of_node);
 | 
				
			||||||
 | 
						tegra_rt5677_dai.codec_of_node = NULL;
 | 
				
			||||||
err:
 | 
					err:
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -296,6 +303,12 @@ static int tegra_rt5677_remove(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tegra_asoc_utils_fini(&machine->util_data);
 | 
						tegra_asoc_utils_fini(&machine->util_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tegra_rt5677_dai.platform_of_node = NULL;
 | 
				
			||||||
 | 
						of_node_put(tegra_rt5677_dai.codec_of_node);
 | 
				
			||||||
 | 
						tegra_rt5677_dai.codec_of_node = NULL;
 | 
				
			||||||
 | 
						of_node_put(tegra_rt5677_dai.cpu_of_node);
 | 
				
			||||||
 | 
						tegra_rt5677_dai.cpu_of_node = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue