Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: alsa-devel@alsa-project.org
Cc: Ville@alsa-project.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Graeme Gregory <graeme@openmoko.org>,
	Tim Niemeyer <reddog@mastersword.de>,
	Frank Mandarino <fmandarino@endrelia.com>
Subject: [PATCH 1/3] ASoC: Fix an error path in neo1973_wm8753
Date: Mon, 1 Sep 2008 17:44:05 +0200	[thread overview]
Message-ID: <20080901174405.73e5ea98@hyperion.delvare> (raw)

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>
---
I couldn't even test-build that one. Tim, Graeme, can any of you
please review and test this patch? Thanks.

 sound/soc/s3c24xx/neo1973_wm8753.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- linux-2.6.27-rc5.orig/sound/soc/s3c24xx/neo1973_wm8753.c	2008-09-01 15:13:17.000000000 +0200
+++ linux-2.6.27-rc5/sound/soc/s3c24xx/neo1973_wm8753.c	2008-09-01 15:22:42.000000000 +0200
@@ -717,12 +717,16 @@ static int __init neo1973_init(void)
 	neo1973_snd_devdata.dev = &neo1973_snd_device->dev;
 	ret = platform_device_add(neo1973_snd_device);
 
-	if (ret)
+	if (ret) {
 		platform_device_put(neo1973_snd_device);
+		return ret;
+	}
 
 	ret = i2c_add_driver(&lm4857_i2c_driver);
-	if (ret != 0)
+	if (ret != 0) {
 		printk(KERN_ERR "can't add i2c driver");
+		platform_device_unregister(neo1973_snd_device);
+	}
 
 	return ret;
 }


-- 
Jean Delvare

                 reply	other threads:[~2008-09-01 15:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080901174405.73e5ea98@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=Ville@alsa-project.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=fmandarino@endrelia.com \
    --cc=graeme@openmoko.org \
    --cc=reddog@mastersword.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox