aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2008-12-02 17:34:52 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:26 -0500
commita8782f669c35df585749caadfbae6456d9e3ac98 (patch)
treee1fe64719a08c8676338d40736a26839a4b4e626
parent9bb1b7e879091f09fc677dca10c5e132b68a9da3 (diff)
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>
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 06f171ab614..66c755c116d 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -742,7 +742,6 @@ static int __devinit snd_cx88_create(struct snd_card *card,
742 core = cx88_core_get(pci); 742 core = cx88_core_get(pci);
743 if (NULL == core) { 743 if (NULL == core) {
744 err = -EINVAL; 744 err = -EINVAL;
745 kfree (chip);
746 return err; 745 return err;
747 } 746 }
748 747
@@ -812,7 +811,7 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
812 811
813 err = snd_cx88_create(card, pci, &chip); 812 err = snd_cx88_create(card, pci, &chip);
814 if (err < 0) 813 if (err < 0)
815 return (err); 814 goto error;
816 815
817 err = snd_cx88_pcm(chip, 0, "CX88 Digital"); 816 err = snd_cx88_pcm(chip, 0, "CX88 Digital");
818 if (err < 0) 817 if (err < 0)