Ver Fonte

ALSA: hda - Fix Oops at reloading beep devices

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>
Takashi Iwai há 15 anos atrás
pai
commit
54f7190b23
1 ficheiros alterados com 7 adições e 3 exclusões
  1. 7 3
      sound/pci/hda/hda_beep.c

+ 7 - 3
sound/pci/hda/hda_beep.c

@@ -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);