Message ID | 20211214040028.2992627-1-tzungbi@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC] ASoC: mediatek: mt8192-mt6359: fix device_node leak | expand |
On Tue, 14 Dec 2021 12:00:28 +0800, Tzung-Bi Shih wrote: > The of_parse_phandle() document: > >>> Use of_node_put() on it when done. > > The driver didn't call of_node_put(). Fixes the leak. > > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: mediatek: mt8192-mt6359: fix device_node leak commit: 4e28491a7a198c668437f2be8a91a76aa52f20eb 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
On Tue, Dec 14, 2021 at 12:00 PM Tzung-Bi Shih <tzungbi@google.com> wrote: > Option 1. Machine driver makes sure the object is valid until registered > > This patch adopts the option. It needs snd_soc_register_card() to call > of_node_get() somewhere to hold the reference count of of_node. However, > I failed to find similar logic in soc-core.c. > > Option 2. Machine driver borrows the reference count > > This is what [1] adopts. Decreasing the reference count in device's > remove() to make sure the object is valid for whole sound card's lifecycle. > > [1]: https://elixir.bootlin.com/linux/v5.16-rc5/source/sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c#L1065 I guess I have found the answer to my original questions. The of_node in snd_soc_dai_link_component in snd_soc_dai_link is mainly for matching the component[4]. snd_soc_component itself should hold the reference count. [4]: https://elixir.bootlin.com/linux/v5.16-rc6/source/sound/soc/soc-core.c#L749 In summary: - ASoC doesn't need to hold the device_node reference counts. - Device nodes can be released after components have bound.
diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index a606133951b7..24a5d0adec1b 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -1172,7 +1172,11 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) return ret; } - return devm_snd_soc_register_card(&pdev->dev, card); + ret = devm_snd_soc_register_card(&pdev->dev, card); + + of_node_put(platform_node); + of_node_put(hdmi_codec); + return ret; } #ifdef CONFIG_OF