Commit f03d68fe authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Jaroslav Kysela

[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: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 548a648b
...@@ -215,15 +215,18 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip) ...@@ -215,15 +215,18 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip)
{ {
struct pmac_beep *beep; struct pmac_beep *beep;
struct input_dev *input_dev; struct input_dev *input_dev;
struct snd_kcontrol *beep_ctl;
void *dmabuf; void *dmabuf;
int err = -ENOMEM; int err = -ENOMEM;
beep = kzalloc(sizeof(*beep), GFP_KERNEL); beep = kzalloc(sizeof(*beep), GFP_KERNEL);
if (! beep)
return -ENOMEM;
dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4, dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
&beep->addr, GFP_KERNEL); &beep->addr, GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!beep || !dmabuf || !input_dev) if (! dmabuf || ! input_dev)
goto fail; goto fail1;
/* FIXME: set more better values */ /* FIXME: set more better values */
input_dev->name = "PowerMac Beep"; input_dev->name = "PowerMac Beep";
...@@ -244,17 +247,24 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip) ...@@ -244,17 +247,24 @@ int __init snd_pmac_attach_beep(struct snd_pmac *chip)
beep->volume = BEEP_VOLUME; beep->volume = BEEP_VOLUME;
beep->running = 0; 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) if (err < 0)
goto fail; goto fail1;
chip->beep = beep;
chip->beep = beep; err = input_register_device(beep->dev);
input_register_device(beep->dev); if (err)
goto fail2;
return 0;
return 0;
fail: input_free_device(input_dev);
kfree(dmabuf); 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); kfree(beep);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment