]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
V4L/DVB (9297): cx18: Fix memory leak on card initialization failure
authorAndy Walls <awalls@radix.net>
Sat, 18 Oct 2008 11:51:28 +0000 (08:51 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 21 Oct 2008 16:20:39 +0000 (14:20 -0200)
On error exit, the cx18_probe() function did not use the proper entry in
cx18_cards[] with kfree() when card init failed; leaking memory.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/cx18/cx18-driver.c

index 085121c2b47f3844aa07e60b21f7b5e4843437b6..ef60f561d956d249c0a2a89c8afbf5a421cc8bd2 100644 (file)
@@ -613,6 +613,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
                                const struct pci_device_id *pci_id)
 {
        int retval = 0;
+       int i;
        int vbi_buf_size;
        u32 devtype;
        struct cx18 *cx;
@@ -836,8 +837,11 @@ err:
        CX18_ERR("Error %d on initialization\n", retval);
        cx18_log_statistics(cx);
 
-       kfree(cx18_cards[cx18_cards_active]);
-       cx18_cards[cx18_cards_active] = NULL;
+       i = cx->num;
+       spin_lock(&cx18_cards_lock);
+       kfree(cx18_cards[i]);
+       cx18_cards[i] = NULL;
+       spin_unlock(&cx18_cards_lock);
        return retval;
 }