Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0fd4345 authored by Julia Lawall's avatar Julia Lawall Committed by Takashi Iwai
Browse files

ALSA: echoaudio - Eliminate use after free

Use the call to snd_card_free in the error handling code at the end of the
function, as in the other error cases.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/

)

// <smpl>
@@
expression E,E2;
@@

snd_card_free(E)
...
(
  E = E2
|
* E
)
// </smpl>

Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f11947c7
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -2184,10 +2184,9 @@ static int __devinit snd_echo_probe(struct pci_dev *pci,
			goto ctl_error;
			goto ctl_error;
#endif
#endif


	if ((err = snd_card_register(card)) < 0) {
	err = snd_card_register(card);
		snd_card_free(card);
	if (err < 0)
		goto ctl_error;
		goto ctl_error;
	}
	snd_printk(KERN_INFO "Card registered: %s\n", card->longname);
	snd_printk(KERN_INFO "Card registered: %s\n", card->longname);


	pci_set_drvdata(pci, chip);
	pci_set_drvdata(pci, chip);