diff options
author | Michael Hunold <devnull@localhost> | 2004-01-03 22:33:16 +0000 |
---|---|---|
committer | Michael Hunold <devnull@localhost> | 2004-01-03 22:33:16 +0000 |
commit | a1b4d25468ad76345f2453e243133e453eed9e5c (patch) | |
tree | dc816deb8b0af882cabe4fcc5221fbe039374e32 | |
parent | accdeb933167f75e912619e94f92e766b157ed79 (diff) | |
download | mediapointer-dvb-s2-a1b4d25468ad76345f2453e243133e453eed9e5c.tar.gz mediapointer-dvb-s2-a1b4d25468ad76345f2453e243133e453eed9e5c.tar.bz2 |
- fix memory leak when using custom pagetables for video dma,
store the pointer in our saa7146_pagetable struct and free it
later on correctly (only used by budget DVB drivers)
- remove some commented out debug code
-rw-r--r-- | linux/drivers/media/common/saa7146_core.c | 21 | ||||
-rw-r--r-- | linux/include/media/saa7146.h | 2 |
2 files changed, 11 insertions, 12 deletions
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c index e581aafe2..5e141af7c 100644 --- a/linux/drivers/media/common/saa7146_core.c +++ b/linux/drivers/media/common/saa7146_core.c @@ -137,7 +137,6 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt) { - struct scatterlist *slist = NULL; int pages = (length+PAGE_SIZE-1)/PAGE_SIZE; char *mem = vmalloc_32(length); int slen = 0; @@ -146,35 +145,36 @@ char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa return NULL; } - if (!(slist = vmalloc_to_sg(mem, pages))) { + if (!(pt->slist = vmalloc_to_sg(mem, pages))) { vfree(mem); return NULL; } if (saa7146_pgtable_alloc(pci, pt)) { - kfree(slist); + kfree(pt->slist); + pt->slist = NULL; vfree(mem); return NULL; } - slen = pci_map_sg(pci,slist,pages,PCI_DMA_FROMDEVICE); - if (0 != saa7146_pgtable_build_single(pci, pt, slist, slen)) { + slen = pci_map_sg(pci,pt->slist,pages,PCI_DMA_FROMDEVICE); + if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen)) { return NULL; } - /* fixme: here's a memory leak: slist never gets freed by any other - function ...*/ return mem; } void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) { -//fm DEB_EE(("pci:%p, pt:%p\n",pci,pt)); - if (NULL == pt->cpu) return; pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); pt->cpu = NULL; + if (NULL != pt->slist) { + kfree(pt->slist); + pt->slist = NULL; + } } int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) @@ -182,11 +182,8 @@ int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) u32 *cpu; dma_addr_t dma_addr; -//fm DEB_EE(("pci:%p, pt:%p\n",pci,pt)); - cpu = pci_alloc_consistent(pci, SAA7146_PGTABLE_SIZE, &dma_addr); if (NULL == cpu) { -//fm ERR(("pci_alloc_consistent() failed.")); return -ENOMEM; } pt->size = SAA7146_PGTABLE_SIZE; diff --git a/linux/include/media/saa7146.h b/linux/include/media/saa7146.h index 034280d24..b3019ceb7 100644 --- a/linux/include/media/saa7146.h +++ b/linux/include/media/saa7146.h @@ -67,6 +67,8 @@ struct saa7146_pgtable { dma_addr_t dma; /* used for offsets for u,v planes for planar capture modes */ unsigned long offset; + /* used for custom pagetables (used for example by budget dvb cards) */ + struct scatterlist *slist; }; struct saa7146_pci_extension_data { |