]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ALSA: hda - Fix Oops at reloading beep devices
authorTakashi Iwai <tiwai@suse.de>
Sun, 27 Dec 2009 12:27:39 +0000 (13:27 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sun, 27 Dec 2009 12:34:01 +0000 (13:34 +0100)
The recent change for supporting dynamic beep device allocation caused
a problem resulting in Oops at reloading the driver.  Also, it ignores
the error from input device registration.

This patch fixes the wrong check in snd_hda_detach_beep_device(), and
returns an error when the input device registration fails properly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_beep.c

index ca3c57a5f8886f309c39d4980d8270e78c72e99c..e4581a42ace56e62ba0e530f5a6cbd360f43b2d3 100644 (file)
@@ -239,8 +239,12 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
        mutex_init(&beep->mutex);
 
        if (beep->mode == HDA_BEEP_MODE_ON) {
-               beep->enabled = 1;
-               snd_hda_do_register(&beep->register_work);
+               int err = snd_hda_do_attach(beep);
+               if (err < 0) {
+                       kfree(beep);
+                       codec->beep = NULL;
+                       return err;
+               }
        }
 
        return 0;
@@ -253,7 +257,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
        if (beep) {
                cancel_work_sync(&beep->register_work);
                cancel_delayed_work(&beep->unregister_work);
-               if (beep->enabled)
+               if (beep->dev)
                        snd_hda_do_detach(beep);
                codec->beep = NULL;
                kfree(beep);