linux/sound
Julia Lawall 73f6a12ed1 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>
2008-11-27 15:42:15 +01:00
..
aoa sound: struct device - replace bus_id with dev_name(), dev_set_name() 2008-11-03 08:57:33 +01:00
arm ALSA: Ensure PXA runtime data is initialised 2008-10-22 17:22:01 +02:00
core Merge branch 'topic/fix/misc' into topic/misc 2008-11-07 09:06:05 +01:00
drivers ALSA: pcsp - Use HRTIMER_CB_IRQSAFE_UNLOCKED 2008-11-14 13:58:43 +01:00
i2c ALSA: revo51: add headphone output 2008-08-25 09:57:17 +02:00
isa ALSA: remove direct access of dev->bus_id in sound/isa/* 2008-11-03 08:57:40 +01:00
mips ALSA: Kill snd_assert() in other places 2008-08-13 11:46:40 +02:00
oss sound: use a common working email address 2008-10-27 16:36:30 +01:00
parisc ALSA: harmony - fix a typo 2008-09-04 10:33:55 +02:00
pci ALSA: sound/pci/mixart/mixart.c: Add missing snd_card_free 2008-11-27 15:42:15 +01:00
pcmcia ALSA: Kill snd_assert() in other places 2008-08-13 11:46:40 +02:00
ppc ALSA: snd-powermac: enable mic on iMac G4 2008-11-18 07:38:00 +01:00
sh ALSA: Fix section for snd-aica platform driver 2008-09-23 08:17:58 +02:00
soc Merge branch 'topic/fix/misc' into topic/misc 2008-11-07 09:06:05 +01:00
sparc ALSA: Kill snd_assert() in other places 2008-08-13 11:46:40 +02:00
spi sound: Convert to menuconfig 2008-05-27 15:56:20 +02:00
synth ALSA: Kill snd_assert() in other places 2008-08-13 11:46:40 +02:00
usb ALSA: snd-usb-caiaq: clean up the control adding code 2008-11-27 08:21:05 +01:00
ac97_bus.c [ALSA] ac97_bus power management 2007-02-09 09:03:54 +01:00
Kconfig sound: make OSS sound core optional 2008-08-29 10:06:21 +02:00
last.c [ALSA] Remove sound/driver.h 2008-01-31 17:29:48 +01:00
Makefile [ALSA] Add SPI devices to ALSA Kconfig and Makefile 2007-10-16 15:57:47 +02:00
sound_core.c sound: use a common working email address 2008-10-27 16:36:30 +01:00
sound_firmware.c Detach sched.h from mm.h 2007-05-21 09:18:19 -07:00