[alsa-devel] [patch] ASoC: sgtl5000: use after free in ldo_regulator_register()

Dan Carpenter error27 at gmail.com
Tue Mar 8 12:39:24 CET 2011

The "ldo" variable was dereferenced after free on the error path.

Signed-off-by: Dan Carpenter <error27 at gmail.com>

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index b7e97c0..1f7217f 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -875,11 +875,13 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
 	ldo->dev = regulator_register(&ldo->desc, codec->dev,
 					  init_data, ldo);
 	if (IS_ERR(ldo->dev)) {
+		int ret = PTR_ERR(ldo->dev);
 		dev_err(codec->dev, "failed to register regulator\n");
-		return PTR_ERR(ldo->dev);
+		return ret;
 	return 0;

More information about the Alsa-devel mailing list