From: Julia Lawall Date: Fri, 2 Apr 2010 12:47:59 +0000 (+0200) Subject: ALSA: echoaudio - Eliminate use after free X-Git-Tag: upstream/snapshot3+hdmi~14707^2~3^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0fd4345f928d72a56e27b23e4cd28c94bf36be5;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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/) // @@ expression E,E2; @@ snd_card_free(E) ... ( E = E2 | * E ) // Signed-off-by: Julia Lawall Signed-off-by: Takashi Iwai --- diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 8dab82d..668a5ec 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -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);