From 793e71b667856ed6163ad0dc7de1f453e9385590 Mon Sep 17 00:00:00 2001 From: Paul Cassella Date: Tue, 8 Feb 2011 22:22:52 -0300 Subject: [PATCH] [media] ivtv: udma: handle get_user_pages() returning fewer pages than we asked for get_user_pages() may return fewer page than we ask for. As we give up and return an error in this case, we need to put_page() each of the pages we did get. [Andy Walls modified the patch, only removing the braces in the 'for' statement, to eliminate a checkpatch warning.] Signed-off-by: Paul Cassella Signed-off-by: Andy Walls Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/ivtv/ivtv-udma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c index 1daf1dd65bf7..69cc8166b20b 100644 --- a/drivers/media/video/ivtv/ivtv-udma.c +++ b/drivers/media/video/ivtv/ivtv-udma.c @@ -132,7 +132,12 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr, if (user_dma.page_count != err) { IVTV_DEBUG_WARN("failed to map user pages, returned %d instead of %d\n", err, user_dma.page_count); - return -EINVAL; + if (err >= 0) { + for (i = 0; i < err; i++) + put_page(dma->map[i]); + return -EINVAL; + } + return err; } dma->page_count = user_dma.page_count; -- 2.20.1