ppc-beep - handle errors from input_register_device()
At Tue, 1 Aug 2006 23:05:54 -0400,
Quoted 2 lines · Dmitry Torokhov
Not tested - no hardware.
I'd rather change the calls of input_register_device() and snd_ctl_add() stuff.
Oh, there are still other leaks in the error path. I'll fix them, too.
BTW, does one need to input_free_device() afterinput_unregister_device()?
thanks,
Takashi
Quoted 52 lines
Signature · 15 lines
-- Dmitry ppc-beep: handle errors from input_register_device() Signed-off-by: Dmitry Torokhov <[email protected]> --- sound/ppc/beep.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) Index: work/sound/ppc/beep.c ===================================================================sound/ppc/beep.c +8
-4@@ -215,6 +215,7 @@ int __init snd_pmac_attach_beep(struct s {struct pmac_beep *beep;struct input_dev *input_dev; +struct snd_kcontrol *beep_ctl;void *dmabuf;int err = -ENOMEM ;@@ -223,7 +224,7 @@ int __init snd_pmac_attach_beep(struct s &beep->addr, GFP_KERNEL); input_dev =input_allocate_device ();if (!beep || !dmabuf || !input_dev) - goto fail; + goto fail1;/* FIXME: set more better values */ input_dev->name ="PowerMac Beep" ;@@ -244,16 +245,21 @@ int __init snd_pmac_attach_beep(struct s 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; -input_register_device (beep->dev); + + err =input_register_device (beep->dev); +if (err)
sound/ppc/beep.c int __init snd_pmac_attach_beep(struct s · line 265
Quoted 10 lines
sound/ppc/beep.c +3
-1+ goto fail2;return 0 ; - fail:input_free_device (input_dev); + fail2:snd_ctl_remove (chip->card, beep_ctl); + fail1:input_free_device (input_dev);kfree (dmabuf);kfree (beep);return err;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Wed, 2 Aug 2006 19:57:06 -0400,
Quoted 9 lines · Dmitry Torokhov
Quoted 3 lines · Takashi Iwai
BTW, does one need to
input_free_device()afterinput_unregister_device()?No,
input_free_device()must not be called afterinput_unregister_device()because theinput_unregister_device()frees memory if it was the last reference.
Thanks, that I supposed, too.
Quoted 4 lines
That's why I like to have
input_register_devicelast.
To keep error path tidy you may either grab and extra reference viainput_get_device()or just setinput_devto NULL -input_free_devicehandles NULLs just fine.
OK, I committed your patch together with other fixes to ALSA tree.
Thanks!
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV