diff options
Diffstat (limited to 'linux/drivers/media/common/saa7146_core.c')
-rw-r--r-- | linux/drivers/media/common/saa7146_core.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c index 452137925..84c6beb92 100644 --- a/linux/drivers/media/common/saa7146_core.c +++ b/linux/drivers/media/common/saa7146_core.c @@ -103,7 +103,9 @@ char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa } slen = pci_map_sg(pci,slist,pages,PCI_DMA_FROMDEVICE); - saa7146_pgtable_build_single(pci, pt, slist, slen); + if (0 != saa7146_pgtable_build_single(pci, pt, slist, slen)) { + return NULL; + } /* fixme: here's a memory leak: slist never gets freed by any other function ...*/ @@ -139,7 +141,7 @@ int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) return 0; } -void saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, +int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int sglen ) { u32 *ptr, fill; @@ -147,7 +149,12 @@ void saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *p int i,p; BUG_ON( 0 == sglen); - + + if (list->offset > PAGE_SIZE) { + DEB_D(("offset > PAGE_SIZE. this should not happen.")); + return -EINVAL; + } + /* if we have a user buffer, the first page may not be aligned to a page boundary. */ pt->offset = list->offset; @@ -177,6 +184,7 @@ void saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *p printk("ptr1 %d: 0x%08x\n",i,ptr[i]); } */ + return 0; } /********************************************************************************/ |