]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/soc/codecs/wm8510.c
ALSA: ASoC: Fix double free and memory leak in many codec drivers
[linux-2.6-omap-h63xx.git] / sound / soc / codecs / wm8510.c
index 67325fd954472f51563b5803b799b69a119eca37..3d998e6a997e5270838a4532c425e154fb8f2bd6 100644 (file)
@@ -693,10 +693,9 @@ static int wm8510_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;
 
@@ -714,7 +713,6 @@ static int wm8510_codec_probe(struct i2c_adapter *adap, int addr, int kind)
        return ret;
 
 err:
-       kfree(codec);
        kfree(i2c);
        return ret;
 }
@@ -782,6 +780,9 @@ static int wm8510_probe(struct platform_device *pdev)
 #else
        /* Add other interfaces here */
 #endif
+
+       if (ret != 0)
+               kfree(codec);
        return ret;
 }