# \[PATCH\] sound: fsl: add missing put\_device() call in imx\_hdmi\_probe()

- Subsystems: FREESCALE SOC SOUND DRIVERS, SOUND, SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC), THE REST
- Maintainers: Shengjiu Wang, Xiubo Li, Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown, Linus Torvalds
- List: linux-arm-kernel
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linux-arm-kernel/2021/12/1599708/t

## \[PATCH\] sound: fsl: add missing put\_device() call in imx\_hdmi\_probe()

- From: Qing Wang \<hidden\>
- Date: 2021-12-07 12:57:17 
- Message: https://ratatoskr.run/linux-arm-kernel/2021/12/1599708.md

```text
From: Wang Qing <redacted>

of_find_device_by_node() takes a reference to the embedded struct device 
which needs to be dropped when error return.

Signed-off-by: Wang Qing <redacted>
---
 sound/soc/fsl/imx-hdmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/imx-hdmi.c b/sound/soc/fsl/imx-hdmi.c
index 929f69b..89fd8ad
--- a/sound/soc/fsl/imx-hdmi.c
+++ b/sound/soc/fsl/imx-hdmi.c
@@ -125,6 +125,7 @@ static int imx_hdmi_probe(struct platform_device *pdev)
 
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
+		put_device(&cpu_pdev->dev);
 		ret = -ENOMEM;
 		goto fail;
 	}
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
```

## Re: \[PATCH\] sound: fsl: add missing put\_device() call in imx\_hdmi\_probe()

- From: Mark Brown \<broonie@kernel.org\>
- Date: 2021-12-08 14:05:15 
- Message: https://ratatoskr.run/linux-arm-kernel/2021/12/1601236.md

```text
On Tue, Dec 07, 2021 at 04:56:58AM -0800, Qing Wang wrote:
> From: Wang Qing <redacted>
> 
> of_find_device_by_node() takes a reference to the embedded struct device 
> which needs to be dropped when error return.

...

>  	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
>  	if (!data) {
> +		put_device(&cpu_pdev->dev);

If it's of_find_device_by_node() you need an of_node_put() since you're
dropping a reference on the OF node.
```
