linux/drivers/media/video/cx88
Julia Lawall a8782f669c V4L/DVB (9796): drivers/media/video/cx88/cx88-alsa.c: Adjust error-handling code
In the function cx88_audio_initdev, the value card has been created using
snd_card_new.  The other error handling code in this function frees the
value using snd_card_free.  I have thus changed the first error case to do
the same.  On the other hand, it may be that card is not sufficiently
initialized at this point to use snd_card_free, in which case something
else should be done to free the memory in the error case.

In the function snd_cx88_create the call kfree(chip) in one error case
looks suspicious, both because it is not done in the other error code, and
because chip points into the middle of the memory allocated by
snd_card_new, ie it is not itself associated with a separate kmalloc.
Therefore I have removed it.

The semantic match that finds the first 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2008-12-30 09:38:26 -02:00
..
cx88-alsa.c V4L/DVB (9796): drivers/media/video/cx88/cx88-alsa.c: Adjust error-handling code 2008-12-30 09:38:26 -02:00
cx88-blackbird.c V4L/DVB (9654): new email address 2008-12-29 17:53:35 -02:00
cx88-cards.c V4L/DVB (9536): WinFast DTV2000 H: add support for missing analog inputs 2008-12-29 17:53:28 -02:00
cx88-core.c V4L/DVB (9497): tda9887/cx88: Adds SECAM/BGH standards 2008-12-29 17:53:25 -02:00
cx88-dvb.c V4L/DVB (9576): cx88-dvb: MFE attachment clean-up for HVR-3000/4000 2008-12-29 17:53:31 -02:00
cx88-i2c.c V4L/DVB (9332): cx88: initial fix for analogue only compilation 2008-10-21 14:31:55 -02:00
cx88-input.c V4L/DVB (9223): MFE: Fix a number of bugs and some tidying up 2008-10-17 17:23:15 -03:00
cx88-mpeg.c V4L/DVB (9654): new email address 2008-12-29 17:53:35 -02:00
cx88-reg.h V4L/DVB (6066): cx88-alsa: Change order of interrupt enabling, fix spurious IRQs 2007-10-09 22:05:55 -03:00
cx88-tvaudio.c V4L/DVB (9269): cx88: add I2S-ADC tvaudio method 2008-10-17 17:29:14 -03:00
cx88-vbi.c V4L/DVB (7094): static memory 2008-04-24 13:42:20 -03:00
cx88-video.c V4L/DVB (9368): VBI fix for cx88 cards 2008-11-11 08:11:23 -02:00
cx88-vp3054-i2c.c v4l-dvb: remove legacy checks to allow support for kernels < 2.6.10 2008-07-20 07:17:52 -03:00
cx88-vp3054-i2c.h V4L/DVB (5629): Cx88: VP3054 support can't be a module when cx88 is compiled in 2007-07-18 14:23:11 -03:00
cx88.h V4L/DVB (9534): cx88: Add support for Prof 6200 DVB-S PCI card 2008-12-29 17:53:28 -02:00
Kconfig V4L/DVB (9885): drivers/media Kconfig's: fix bugzilla #12204 2008-12-16 16:43:59 -02:00
Makefile V4L/DVB(7767): Move tuners to common/tuners 2008-04-29 18:41:37 -03:00