diff options
author | Dmitry Torokhov <dtor@mail.ru> | 2006-08-03 15:06:14 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-09-23 10:39:55 +0200 |
commit | f03d68fe343d70bb06ecdb3d70dcf0e678ed99f9 (patch) | |
tree | 5d5a232219a95acfb2bfe449968b7fbb0f1e5df8 | |
parent | 548a648b98318e4b843b636dd2c7f42377e19a00 (diff) | |
download | kernel_samsung_crespo-f03d68fe343d70bb06ecdb3d70dcf0e678ed99f9.zip kernel_samsung_crespo-f03d68fe343d70bb06ecdb3d70dcf0e678ed99f9.tar.gz kernel_samsung_crespo-f03d68fe343d70bb06ecdb3d70dcf0e678ed99f9.tar.bz2 |
[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>
-rw-r--r-- | sound/ppc/beep.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index 5fec1e5..5f38f67 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) { struct pmac_beep *beep; struct input_dev *input_dev; + struct snd_kcontrol *beep_ctl; void *dmabuf; int err = -ENOMEM; beep = kzalloc(sizeof(*beep), GFP_KERNEL); + if (! beep) + return -ENOMEM; dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4, &beep->addr, GFP_KERNEL); input_dev = input_allocate_device(); - if (!beep || !dmabuf || !input_dev) - goto fail; + if (! dmabuf || ! input_dev) + goto fail1; /* FIXME: set more better values */ input_dev->name = "PowerMac Beep"; @@ -244,17 +247,24 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip) beep->volume = BEEP_VOLUME; beep->running = 0; - err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_pmac_beep_mixer, chip)); + beep_ctl = snd_ctl_new1(&snd_pmac_beep_mixer, chip); + err = snd_ctl_add(chip->card, beep_ctl); if (err < 0) - goto fail; + goto fail1; + + chip->beep = beep; - chip->beep = beep; - input_register_device(beep->dev); - - return 0; - - fail: input_free_device(input_dev); - kfree(dmabuf); + err = input_register_device(beep->dev); + if (err) + goto fail2; + + return 0; + + fail2: snd_ctl_remove(chip->card, beep_ctl); + fail1: input_free_device(input_dev); + if (dmabuf) + dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4, + dmabuf, beep->addr); kfree(beep); return err; } |