[2.4] Memleak and incorrect return value in emu10k1 emu10k1_audio_open()
Hello!
There is trivial memleak ion error exit path and incorrect value returned. Also seems it is not so bad idea to free allocated RAM before BUG(), too. See the patch.
Found with help of smatch + enhanced unfree script.
Bye,
Oleg
===== drivers/sound/emu10k1/audio.c 1.13 vs edited =====
drivers/sound/emu10k1/audio.c +4 -1
@@ -1135,7 +1135,8 @@if ((wiinst = (struct wiinst *)kmalloc (sizeof (struct wiinst ),GFP_KERNEL )) ==NULL ) {ERROR (); -return -ENODEV ; +kfree (wave_dev); +return -ENOMEM ; } wiinst->recsrc = card->wavein.recsrc;
@@ -1161,6 +1162,8 @@ wiinst->format.channels =hweight32 (wiinst->fxwc);break ;default : +kfree (wave_dev); +kfree (wiinst);BUG ();break ; }