Commit 54f7190b authored by Takashi Iwai's avatar Takashi Iwai

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: default avatarTakashi Iwai <tiwai@suse.de>
parent 411fe85c
......@@ -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);
......
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