fix usbmixer double kfree.
snd_ctl_add() kfree's the kcontrol already if we fail there, so this driver is currently doing a double kfree.
Coverity bug #959
sound/usb/usbmixer.c renamed from sound/usb/usbmixer.c~ +0 -1
@@ -434,7 +434,6 @@ static int add_control_to_empty(struct m kctl->id.index++;if ((err =snd_ctl_add (state->chip->card, kctl)) <0 ) {snd_printd (KERN_ERR "cannot add control (err = %d)\n" , err); -snd_ctl_free_one (kctl);return err; } cval->elem_id = &kctl->id;
Signature · 1 line
http://www.codemonkey.org.uk
Takashi Iwai
AppliedAt Mon, 6 Mar 2006 03:49:51 -0500,
Quoted 12 lines · Dave Jones
snd_ctl_add()kfree's the kcontrol already if we fail there, so this driver is currently doing a double kfree.Coverity bug #959
Signed-off-by Dave Jones <[email protected]>
sound/usb/usbmixer.c static int add_control_to_empty(struct m · line 439
Quoted 7 lines
sound/usb/usbmixer.c renamed from sound/usb/usbmixer.c~ +0
-1@@ -434,7 +434,6 @@ static int add_control_to_empty(struct m kctl->id.index++;if ((err =snd_ctl_add (state->chip->card, kctl)) <0 ) {snd_printd (KERN_ERR "cannot add control (err = %d)\n" , err); -snd_ctl_free_one (kctl);return err; } cval->elem_id = &kctl->id;
Thanks, applied to ALSA tree now, too.
Takashi
Quoted 3 lines · Dave Jones
snd_ctl_add()kfree's the kcontrol already if we fail there, so this driver is currently doing a double kfree.
Well sometimes it does. If we hit one of those snd_assert() abominations, snd_ctl_add() will return error without freeing the kcontrol.
Still, a leak is better than a double-free.
Quoted 10 lines
sound/usb/usbmixer.c renamed from sound/usb/usbmixer.c~ +0
-1@@ -434,7 +434,6 @@ static int add_control_to_empty(struct m kctl->id.index++;if ((err =snd_ctl_add (state->chip->card, kctl)) <0 ) {snd_printd (KERN_ERR "cannot add control (err = %d)\n" , err); -snd_ctl_free_one (kctl);return err; } cval->elem_id = &kctl->id;
At Mon, 6 Mar 2006 16:41:11 -0800,
Quoted 8 lines · Andrew Morton
Quoted 3 lines · Dave Jones
snd_ctl_add()kfree's the kcontrol already if we fail there, so this driver is currently doing a double kfree.Well sometimes it does. If we hit one of those
snd_assert()abominations,snd_ctl_add()will return error without freeing the kcontrol.
Indeed. I'll fix them later.
Quoted 1 line
Still, a leak is better than a double-free.
Yep :)
thanks,
Takashi