From ff086575b7fbfcf48c1e2bc6f8914cbfc2c4ea37 Mon Sep 17 00:00:00 2001 From: Andy Walls Date: Sat, 18 Oct 2008 08:51:28 -0300 Subject: V4L/DVB (9297): cx18: Fix memory leak on card initialization failure 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 Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/cx18/cx18-driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/media') diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 085121c2b47..ef60f561d95 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c @@ -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; } -- cgit v1.2.3