]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/soc/codecs/ak4535.c
ALSA: ASoC: Fix double free and memory leak in many codec drivers
[linux-2.6-omap-h63xx.git] / sound / soc / codecs / ak4535.c
index 469266e881d87ff3cdc02a173f1a671ae515117e..7da9f467b7b83f06d4fdf02a44e05ba4ff530b97 100644 (file)
@@ -329,7 +329,7 @@ static int ak4535_add_widgets(struct snd_soc_codec *codec)
        return 0;
 }
 
-static int ak4535_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
+static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai,
        int clk_id, unsigned int freq, int dir)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
@@ -369,7 +369,7 @@ static int ak4535_hw_params(struct snd_pcm_substream *substream,
        return 0;
 }
 
-static int ak4535_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
+static int ak4535_set_dai_fmt(struct snd_soc_dai *codec_dai,
                unsigned int fmt)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
@@ -394,7 +394,7 @@ static int ak4535_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
        return 0;
 }
 
-static int ak4535_mute(struct snd_soc_codec_dai *dai, int mute)
+static int ak4535_mute(struct snd_soc_dai *dai, int mute)
 {
        struct snd_soc_codec *codec = dai->codec;
        u16 mute_reg = ak4535_read_reg_cache(codec, AK4535_DAC) & 0xffdf;
@@ -436,7 +436,7 @@ static int ak4535_set_bias_level(struct snd_soc_codec *codec,
                SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
                SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
 
-struct snd_soc_codec_dai ak4535_dai = {
+struct snd_soc_dai ak4535_dai = {
        .name = "AK4535",
        .playback = {
                .stream_name = "Playback",
@@ -562,10 +562,9 @@ static int ak4535_codec_probe(struct i2c_adapter *adap, int addr, int kind)
        client_template.addr = addr;
 
        i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
-       if (i2c == NULL) {
-               kfree(codec);
+       if (i2c == NULL)
                return -ENOMEM;
-       }
+
        i2c_set_clientdata(i2c, codec);
        codec->control_data = i2c;
 
@@ -583,7 +582,6 @@ static int ak4535_codec_probe(struct i2c_adapter *adap, int addr, int kind)
        return ret;
 
 err:
-       kfree(codec);
        kfree(i2c);
        return ret;
 }
@@ -660,6 +658,11 @@ static int ak4535_probe(struct platform_device *pdev)
 #else
        /* Add other interfaces here */
 #endif
+
+       if (ret != 0) {
+               kfree(codec->private_data);
+               kfree(codec);
+       }
        return ret;
 }