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>
This commit is contained in:
@ -239,8 +239,12 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
|
|||||||
mutex_init(&beep->mutex);
|
mutex_init(&beep->mutex);
|
||||||
|
|
||||||
if (beep->mode == HDA_BEEP_MODE_ON) {
|
if (beep->mode == HDA_BEEP_MODE_ON) {
|
||||||
beep->enabled = 1;
|
int err = snd_hda_do_attach(beep);
|
||||||
snd_hda_do_register(&beep->register_work);
|
if (err < 0) {
|
||||||
|
kfree(beep);
|
||||||
|
codec->beep = NULL;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -253,7 +257,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
|
|||||||
if (beep) {
|
if (beep) {
|
||||||
cancel_work_sync(&beep->register_work);
|
cancel_work_sync(&beep->register_work);
|
||||||
cancel_delayed_work(&beep->unregister_work);
|
cancel_delayed_work(&beep->unregister_work);
|
||||||
if (beep->enabled)
|
if (beep->dev)
|
||||||
snd_hda_do_detach(beep);
|
snd_hda_do_detach(beep);
|
||||||
codec->beep = NULL;
|
codec->beep = NULL;
|
||||||
kfree(beep);
|
kfree(beep);
|
||||||
|
Reference in New Issue
Block a user