From: Paul Cassella <fortytwo-i...@manetheren.bigw.org> 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.
Signed-off-by: Paul Cassella <fortytwo-i...@manetheren.bigw.org> --- I'm running with this on 2.6.37, though haven't triggered the condition. This patch is against staging/for_v2.6.39, which compiles cleanly with it. I'm not sure -EINVAL is the best return code vs -EFAULT or -ENOMEM, but this mod doesn't change it. drivers/media/video/ivtv/ivtv-udma.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c index 1daf1dd..443ca35 100644 --- a/drivers/media/video/ivtv/ivtv-udma.c +++ b/drivers/media/video/ivtv/ivtv-udma.c @@ -132,7 +132,13 @@ 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; -- 1.7.2.3 _______________________________________________ ivtv-devel mailing list ivtv-devel@ivtvdriver.org http://ivtvdriver.org/mailman/listinfo/ivtv-devel