Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: stm32: sai: fix device leak on probe

Make sure to drop the reference taken when looking up the sync provider
device and its driver data during DAI probe on probe failures and on
unbind.

Note that holding a reference to a device does not prevent its driver
data from going away so there is no point in keeping the reference.

Fixes: 7dd0d835582f ("ASoC: stm32: sai: simplify sync modes management")
Fixes: 1c3816a19487 ("ASoC: stm32: sai: add missing put_device()")
Cc: stable@vger.kernel.org # 4.16: 1c3816a19487
Cc: olivier moysan <olivier.moysan@st.com>
Cc: Wen Yang <yellowriver2010@hotmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: olivier moysan <olivier.moysan@foss.st.com>
Link: https://patch.msgid.link/20251124104908.15754-2-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Johan Hovold and committed by
Mark Brown
e26ff429 ac3fd01e

+1 -1
+1 -1
sound/soc/stm/stm32_sai.c
··· 143 143 } 144 144 145 145 sai_provider = platform_get_drvdata(pdev); 146 + put_device(&pdev->dev); 146 147 if (!sai_provider) { 147 148 dev_err(&sai_client->pdev->dev, 148 149 "SAI sync provider data not found\n"); ··· 160 159 ret = stm32_sai_sync_conf_provider(sai_provider, synco); 161 160 162 161 error: 163 - put_device(&pdev->dev); 164 162 of_node_put(np_provider); 165 163 return ret; 166 164 }