aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-dma-sg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/videobuf-dma-sg.c')
-rw-r--r--drivers/media/video/videobuf-dma-sg.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 03a7b946bd54..bc6d5aba0fe6 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * helper functions for SG DMA video4linux capture buffers 2 * helper functions for SG DMA video4linux capture buffers
3 * 3 *
4 * The functions expect the hardware being able to scatter gatter 4 * The functions expect the hardware being able to scatter gather
5 * (i.e. the buffers are not linear in physical memory, but fragmented 5 * (i.e. the buffers are not linear in physical memory, but fragmented
6 * into PAGE_SIZE chunks). They also assume the driver does not need 6 * into PAGE_SIZE chunks). They also assume the driver does not need
7 * to touch the video data. 7 * to touch the video data.
@@ -80,17 +80,15 @@ struct scatterlist*
80videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) 80videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset)
81{ 81{
82 struct scatterlist *sglist; 82 struct scatterlist *sglist;
83 int i = 0; 83 int i;
84 84
85 if (NULL == pages[0]) 85 if (NULL == pages[0])
86 return NULL; 86 return NULL;
87 sglist = kcalloc(nr_pages, sizeof(*sglist), GFP_KERNEL); 87 sglist = kmalloc(nr_pages * sizeof(*sglist), GFP_KERNEL);
88 if (NULL == sglist) 88 if (NULL == sglist)
89 return NULL; 89 return NULL;
90 sg_init_table(sglist, nr_pages); 90 sg_init_table(sglist, nr_pages);
91 91
92 if (NULL == pages[0])
93 goto nopage;
94 if (PageHighMem(pages[0])) 92 if (PageHighMem(pages[0]))
95 /* DMA to highmem pages might not work */ 93 /* DMA to highmem pages might not work */
96 goto highmem; 94 goto highmem;