This will call twice platform_device_put() if both platform_device_add() and snd_soc_register_card() fails. return early on error to avoid duplicating the error code logic. Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx> --- changes in v2: - use return statement to return early when fails - rebase on top of commit 559089e0a93d ("vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP") --- sound/soc/fsl/pcm030-audio-fabric.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index 83b4a22bf15a..096a37993ad3 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -89,13 +89,16 @@ static int pcm030_fabric_probe(struct platform_device *op) dev_err(&op->dev, "request_module returned: %d\n", ret); pdata->codec_device = platform_device_alloc("wm9712-codec", -1); - if (!pdata->codec_device) + if (!pdata->codec_device) { dev_err(&op->dev, "platform_device_alloc() failed\n"); + return -ENOMEM; + } ret = platform_device_add(pdata->codec_device); if (ret) { dev_err(&op->dev, "platform_device_add() failed: %d\n", ret); platform_device_put(pdata->codec_device); + return ret; } ret = snd_soc_register_card(card); @@ -103,6 +106,7 @@ static int pcm030_fabric_probe(struct platform_device *op) dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); platform_device_del(pdata->codec_device); platform_device_put(pdata->codec_device); + return ret; } platform_set_drvdata(op, pdata); -- 2.17.1