diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-09-01 11:44:05 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-09-09 03:11:07 -0400 |
commit | d280289e799dcdf5913e8935bffe136d7594e26d (patch) | |
tree | e9fd22eb177d971895093583a70ef6e54db1f899 /sound/soc/s3c24xx | |
parent | dfdf34bbcbb2687d3a5fa723279124df9e309195 (diff) |
sound: ASoC: Fix an error path in neo1973_wm8753
The error handling in neo1973_init is incorrect:
* If platform_device_add fails, we go on with the rest of the
initialization instead of bailing out. Things will break when the
module is removed (platform_device_unregister called on a device
that wasn't registered.)
* If i2c_add_driver fails, we return an error so the module will not
load, but we don't unregister neo1973_snd_device, so we are leaking
resources.
Add the missing error handling.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Tim Niemeyer <reddog@mastersword.de>
Cc: Graeme Gregory <graeme@openmoko.org>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/soc/s3c24xx')
-rw-r--r-- | sound/soc/s3c24xx/neo1973_wm8753.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 8089f8ee05c0..3aa441f19ae7 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c | |||
@@ -717,12 +717,16 @@ static int __init neo1973_init(void) | |||
717 | neo1973_snd_devdata.dev = &neo1973_snd_device->dev; | 717 | neo1973_snd_devdata.dev = &neo1973_snd_device->dev; |
718 | ret = platform_device_add(neo1973_snd_device); | 718 | ret = platform_device_add(neo1973_snd_device); |
719 | 719 | ||
720 | if (ret) | 720 | if (ret) { |
721 | platform_device_put(neo1973_snd_device); | 721 | platform_device_put(neo1973_snd_device); |
722 | return ret; | ||
723 | } | ||
722 | 724 | ||
723 | ret = i2c_add_driver(&lm4857_i2c_driver); | 725 | ret = i2c_add_driver(&lm4857_i2c_driver); |
724 | if (ret != 0) | 726 | if (ret != 0) { |
725 | printk(KERN_ERR "can't add i2c driver"); | 727 | printk(KERN_ERR "can't add i2c driver"); |
728 | platform_device_unregister(neo1973_snd_device); | ||
729 | } | ||
726 | 730 | ||
727 | return ret; | 731 | return ret; |
728 | } | 732 | } |