summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-dma-sg.c
diff options
context:
space:
mode:
authorNewson Edouard <newsondev@gmail.com>2011-04-19 11:54:54 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 17:52:19 -0300
commit45f239ab82b2a808103a0fae02594961b09c5c8b (patch)
treea42b4115f12ced98c6c4a6a5a7b990e3c1d8ff37 /drivers/media/video/videobuf-dma-sg.c
parent4bbcd849b07259211dfe6d3168e669e89bbd19ea (diff)
downloadblackbird-op-linux-45f239ab82b2a808103a0fae02594961b09c5c8b.tar.gz
blackbird-op-linux-45f239ab82b2a808103a0fae02594961b09c5c8b.zip
[media] videobuf_pages_to_sg: sglist[0] length problem
On function videobuf_pages_to_sg the statement sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset) will fail if size is less than PAGE_SIZE. Signed-off-by: Newson Edouard <newsondev@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-dma-sg.c')
-rw-r--r--drivers/media/video/videobuf-dma-sg.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index ddb8f4b46c03..f300deafd268 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -108,8 +108,9 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages,
if (PageHighMem(pages[0]))
/* DMA to highmem pages might not work */
goto highmem;
- sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset);
- size -= PAGE_SIZE - offset;
+ sg_set_page(&sglist[0], pages[0],
+ min_t(size_t, PAGE_SIZE - offset, size), offset);
+ size -= min_t(size_t, PAGE_SIZE - offset, size);
for (i = 1; i < nr_pages; i++) {
if (NULL == pages[i])
goto nopage;
OpenPOWER on IntegriCloud