Skip to content

Commit 740dc3e

Browse files
Yuuoniybroonie
authored andcommitted
ASoC: atmel: Fix error handling in sam9x5_wm8731_driver_probe
The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. This function only calls of_node_put() in the regular path. And it will cause refcount leak in error path. Fixes: fdbcb3c ("ASoC: atmel: machine driver for at91sam9x5-wm8731 boards") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Link: https://lore.kernel.org/r/20220316111530.4551-1-linmq006@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cc5d8ac commit 740dc3e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

sound/soc/atmel/sam9x5_wm8731.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
142142
if (!cpu_np) {
143143
dev_err(&pdev->dev, "atmel,ssc-controller node missing\n");
144144
ret = -EINVAL;
145-
goto out;
145+
goto out_put_codec_np;
146146
}
147147
dai->cpus->of_node = cpu_np;
148148
dai->platforms->of_node = cpu_np;
@@ -153,12 +153,9 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
153153
if (ret != 0) {
154154
dev_err(&pdev->dev, "Failed to set SSC %d for audio: %d\n",
155155
ret, priv->ssc_id);
156-
goto out;
156+
goto out_put_cpu_np;
157157
}
158158

159-
of_node_put(codec_np);
160-
of_node_put(cpu_np);
161-
162159
ret = devm_snd_soc_register_card(&pdev->dev, card);
163160
if (ret) {
164161
dev_err(&pdev->dev, "Platform device allocation failed\n");
@@ -167,10 +164,14 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev)
167164

168165
dev_dbg(&pdev->dev, "%s ok\n", __func__);
169166

170-
return ret;
167+
goto out_put_cpu_np;
171168

172169
out_put_audio:
173170
atmel_ssc_put_audio(priv->ssc_id);
171+
out_put_cpu_np:
172+
of_node_put(cpu_np);
173+
out_put_codec_np:
174+
of_node_put(codec_np);
174175
out:
175176
return ret;
176177
}

0 commit comments

Comments
 (0)