lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220420021855.8224-1-linmq006@gmail.com>
Date:   Wed, 20 Apr 2022 02:18:52 +0000
From:   Miaoqian Lin <linmq006@...il.com>
To:     Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>,
        Miaoqian Lin <linmq006@...il.com>, alsa-devel@...a-project.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH v2] ASoC: fsl: Fix error handling in pcm030_fabric_probe

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@...il.com>
---
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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ