]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] omap3isp: queue: Don't corrupt buf->npages when get_user_pages() fails
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 7 Apr 2011 16:30:14 +0000 (13:30 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 19 Apr 2011 14:29:56 +0000 (11:29 -0300)
get_user_pages() can return a negative error code when it fails. Set
buf->npages to 0 in that case, to prevent isp_video_buffer_cleanup()
from releasing invalid pages.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/omap3isp/ispqueue.c

index c91e56a5791e616521d35c2b111c9ec31966f7cc..9c317148205f82a73cb774607ca0a2ea412d2ea6 100644 (file)
@@ -339,7 +339,7 @@ static int isp_video_buffer_prepare_user(struct isp_video_buffer *buf)
        up_read(&current->mm->mmap_sem);
 
        if (ret != buf->npages) {
-               buf->npages = ret;
+               buf->npages = ret < 0 ? 0 : ret;
                isp_video_buffer_cleanup(buf);
                return -EFAULT;
        }