Skip to content

Commit

Permalink
ALSA: echoaudio - Eliminate use after free
Browse files Browse the repository at this point in the history
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: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Julia Lawall authored and Takashi Iwai committed Apr 4, 2010
1 parent f11947c commit a0fd434
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sound/pci/echoaudio/echoaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,10 +2184,9 @@ static int __devinit snd_echo_probe(struct pci_dev *pci,
goto ctl_error;
#endif

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

pci_set_drvdata(pci, chip);
Expand Down

0 comments on commit a0fd434

Please sign in to comment.