From: Vasiliy Kulikov <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Ian Lartey <ian@opensource.wolfsonmicro.com>,
Dimitris Papastamos <dp@opensource.wolfsonmicro.com>,
Liam Girdwood <lrg@slimlogic.co.uk>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: wm8804: fix error handling code
Date: Sun, 10 Oct 2010 17:29:04 +0000 [thread overview]
Message-ID: <1286731745-18169-1-git-send-email-segooon@gmail.com> (raw)
kzalloc() returns NULL on error, not ERR_PTR().
Also wm8804_modinit() didn't called i2c_del_driver() if
spi_register_driver() failed.
Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
Compile tested.
sound/soc/codecs/wm8804.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index 642b07c..ff4dffd 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -720,8 +720,8 @@ static int __devinit wm8804_spi_probe(struct spi_device *spi)
int ret;
wm8804 = kzalloc(sizeof *wm8804, GFP_KERNEL);
- if (IS_ERR(wm8804))
- return PTR_ERR(wm8804);
+ if (!wm8804)
+ return -ENOMEM;
wm8804->control_type = SND_SOC_SPI;
spi_set_drvdata(spi, wm8804);
@@ -758,8 +758,8 @@ static __devinit int wm8804_i2c_probe(struct i2c_client *i2c,
int ret;
wm8804 = kzalloc(sizeof *wm8804, GFP_KERNEL);
- if (IS_ERR(wm8804))
- return PTR_ERR(wm8804);
+ if (!wm8804)
+ return -ENOMEM;
wm8804->control_type = SND_SOC_I2C;
i2c_set_clientdata(i2c, wm8804);
@@ -804,6 +804,7 @@ static int __init wm8804_modinit(void)
if (ret) {
printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
ret);
+ goto err;
}
#endif
#if defined(CONFIG_SPI_MASTER)
@@ -811,7 +812,13 @@ static int __init wm8804_modinit(void)
if (ret != 0) {
printk(KERN_ERR "Failed to register wm8804 SPI driver: %d\n",
ret);
+ goto err_i2c;
}
+err_i2c:
+#endif
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+ i2c_del_driver(&wm8804_i2c_driver);
+err:
#endif
return ret;
}
--
1.7.0.4
next reply other threads:[~2010-10-10 17:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-10 17:29 Vasiliy Kulikov [this message]
2010-10-11 12:00 ` [PATCH] ASoC: wm8804: fix error handling code Mark Brown
2010-10-11 12:15 ` Vasiliy Kulikov
2010-10-11 12:36 ` Mark Brown
2010-10-11 12:50 ` Vasiliy Kulikov
2010-10-11 12:59 ` Mark Brown
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=1286731745-18169-1-git-send-email-segooon@gmail.com \
--to=segooon@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dp@opensource.wolfsonmicro.com \
--cc=ian@opensource.wolfsonmicro.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=perex@perex.cz \
--cc=tiwai@suse.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