diff options
author | Julia Lawall <julia@diku.dk> | 2008-11-27 09:40:40 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-11-27 09:42:15 -0500 |
commit | 73f6a12ed187b7e7ac9334d1419ba7bf7ac1be26 (patch) | |
tree | fd88332a69ce13ca9253e586a6c5d828f747d388 /sound/pci/pcxhr | |
parent | 12666f050b3b4b122f61ef12707f33fadb4a78b5 (diff) |
ALSA: sound/pci/mixart/mixart.c: Add missing snd_card_free
The function snd_mixart_create creates a link between mgr and card that
allows snd_mixart_free to free card as well. But if snd_mixart_create
fails, then the link has not been created and card has to be freed explicitly.
The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
statement S,S1;
position p1,p2,p3;
expression E,E1;
type T,T1;
expression *ptr != NULL;
@@
(
if ((x@p1 = snd_card_new(...)) == NULL) S
|
x@p1 = snd_card_new(...);
)
... when != snd_card_free(...,(T)x,...)
when != if (...) { <+... snd_card_free(...,(T)x,...) ...+> }
when != true x == NULL || ...
when != x = E
when != E = (T)x
when any
(
if (x == NULL || ...) S1
|
if@p2 (...) {
... when != snd_card_free(...,(T1)x,...)
when != if (...) { <+... snd_card_free(...,(T1)x,...) ...+> }
when != x = E1
when != E1 = (T1)x
(
return \(0\|<+...x...+>\|ptr\);
|
return@p3 ...;
)
}
)
@ script:python @
p1 << r.p1;
p3 << r.p3;
@@
print "* file: %s snd_card_new: %s return: %s" % (p1[0].file,p1[0].line,p3[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/pcxhr')
-rw-r--r-- | sound/pci/pcxhr/pcxhr.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 0e06c6c9fcc0..58621206a2b3 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c | |||
@@ -1024,7 +1024,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, | |||
1024 | .dev_free = pcxhr_chip_dev_free, | 1024 | .dev_free = pcxhr_chip_dev_free, |
1025 | }; | 1025 | }; |
1026 | 1026 | ||
1027 | mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1027 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
1028 | if (! chip) { | 1028 | if (! chip) { |
1029 | snd_printk(KERN_ERR "cannot allocate chip\n"); | 1029 | snd_printk(KERN_ERR "cannot allocate chip\n"); |
1030 | return -ENOMEM; | 1030 | return -ENOMEM; |
@@ -1050,6 +1050,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, | |||
1050 | return err; | 1050 | return err; |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | mgr->chip[idx] = chip; | ||
1053 | snd_card_set_dev(card, &mgr->pci->dev); | 1054 | snd_card_set_dev(card, &mgr->pci->dev); |
1054 | 1055 | ||
1055 | return 0; | 1056 | return 0; |
@@ -1307,6 +1308,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1307 | sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); | 1308 | sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); |
1308 | 1309 | ||
1309 | if ((err = pcxhr_create(mgr, card, i)) < 0) { | 1310 | if ((err = pcxhr_create(mgr, card, i)) < 0) { |
1311 | snd_card_free(card); | ||
1310 | pcxhr_free(mgr); | 1312 | pcxhr_free(mgr); |
1311 | return err; | 1313 | return err; |
1312 | } | 1314 | } |