aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc/beep.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@mail.ru>2006-08-03 09:06:14 -0400
committerJaroslav Kysela <perex@suse.cz>2006-09-23 04:39:55 -0400
commitf03d68fe343d70bb06ecdb3d70dcf0e678ed99f9 (patch)
tree5d5a232219a95acfb2bfe449968b7fbb0f1e5df8 /sound/ppc/beep.c
parent548a648b98318e4b843b636dd2c7f42377e19a00 (diff)
[ALSA] ppc-beep - handle errors from input_register_device()
ppc-beep: handle errors from input_register_device() (Also fixed the wrong memory release in the error path.) Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/ppc/beep.c')
-rw-r--r--sound/ppc/beep.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c
index 5fec1e58f310..5f38f670102c 100644
--- a/sound/ppc/beep.c
+++ b/sound/ppc/beep.c
@@ -215,15 +215,18 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip)
215{ 215{
216 struct pmac_beep *beep; 216 struct pmac_beep *beep;
217 struct input_dev *input_dev; 217 struct input_dev *input_dev;
218 struct snd_kcontrol *beep_ctl;
218 void *dmabuf; 219 void *dmabuf;
219 int err = -ENOMEM; 220 int err = -ENOMEM;
220 221
221 beep = kzalloc(sizeof(*beep), GFP_KERNEL); 222 beep = kzalloc(sizeof(*beep), GFP_KERNEL);
223 if (! beep)
224 return -ENOMEM;
222 dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4, 225 dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
223 &beep->addr, GFP_KERNEL); 226 &beep->addr, GFP_KERNEL);
224 input_dev = input_allocate_device(); 227 input_dev = input_allocate_device();
225 if (!beep || !dmabuf || !input_dev) 228 if (! dmabuf || ! input_dev)
226 goto fail; 229 goto fail1;
227 230
228 /* FIXME: set more better values */ 231 /* FIXME: set more better values */
229 input_dev->name = "PowerMac Beep"; 232 input_dev->name = "PowerMac Beep";
@@ -244,17 +247,24 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip)
244 beep->volume = BEEP_VOLUME; 247 beep->volume = BEEP_VOLUME;
245 beep->running = 0; 248 beep->running = 0;
246 249
247 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_pmac_beep_mixer, chip)); 250 beep_ctl = snd_ctl_new1(&snd_pmac_beep_mixer, chip);
251 err = snd_ctl_add(chip->card, beep_ctl);
248 if (err < 0) 252 if (err < 0)
249 goto fail; 253 goto fail1;
254
255 chip->beep = beep;
250 256
251 chip->beep = beep; 257 err = input_register_device(beep->dev);
252 input_register_device(beep->dev); 258 if (err)
253 259 goto fail2;
254 return 0; 260
255 261 return 0;
256 fail: input_free_device(input_dev); 262
257 kfree(dmabuf); 263 fail2: snd_ctl_remove(chip->card, beep_ctl);
264 fail1: input_free_device(input_dev);
265 if (dmabuf)
266 dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
267 dmabuf, beep->addr);
258 kfree(beep); 268 kfree(beep);
259 return err; 269 return err;
260} 270}