diff options
author | Newson Edouard <newsondev@gmail.com> | 2011-04-19 10:54:54 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:52:19 -0400 |
commit | 45f239ab82b2a808103a0fae02594961b09c5c8b (patch) | |
tree | a42b4115f12ced98c6c4a6a5a7b990e3c1d8ff37 /drivers/media/video/videobuf-dma-sg.c | |
parent | 4bbcd849b07259211dfe6d3168e669e89bbd19ea (diff) |
[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.c | 5 |
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, | |||
108 | if (PageHighMem(pages[0])) | 108 | if (PageHighMem(pages[0])) |
109 | /* DMA to highmem pages might not work */ | 109 | /* DMA to highmem pages might not work */ |
110 | goto highmem; | 110 | goto highmem; |
111 | sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); | 111 | sg_set_page(&sglist[0], pages[0], |
112 | size -= PAGE_SIZE - offset; | 112 | min_t(size_t, PAGE_SIZE - offset, size), offset); |
113 | size -= min_t(size_t, PAGE_SIZE - offset, size); | ||
113 | for (i = 1; i < nr_pages; i++) { | 114 | for (i = 1; i < nr_pages; i++) { |
114 | if (NULL == pages[i]) | 115 | if (NULL == pages[i]) |
115 | goto nopage; | 116 | goto nopage; |