patch-2.4.23 linux-2.4.23/drivers/usb/vicam.c

Next file: linux-2.4.23/drivers/usb/w9968cf.c
Previous file: linux-2.4.23/drivers/usb/usbnet.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.22/drivers/usb/vicam.c linux-2.4.23/drivers/usb/vicam.c
@@ -969,18 +969,20 @@
 			if (cam->framebuf_read_start + count <=
 			    cam->framebuf_size) {
 				// count does not exceed available bytes
-				copy_to_user(buf,
-					     (cam->framebuf) +
-					     cam->framebuf_read_start, count);
+				if (copy_to_user(buf,
+						 (cam->framebuf) +
+						 cam->framebuf_read_start, count))
+					return -EFAULT;
 				cam->framebuf_read_start += count;
 				return count;
 			} else {
 				count =
 				    cam->framebuf_size -
 				    cam->framebuf_read_start;
-				copy_to_user(buf,
-					     (cam->framebuf) +
-					     cam->framebuf_read_start, count);
+				if (copy_to_user(buf,
+						 (cam->framebuf) +
+						 cam->framebuf_read_start, count))
+					return -EFAULT;
 				cam->framebuf_read_start = cam->framebuf_size;
 				return count;
 			}
@@ -1002,7 +1004,10 @@
 	if (count > cam->framebuf_size)
 		count = cam->framebuf_size;
 
-	copy_to_user(buf, cam->framebuf, count);
+	if (copy_to_user(buf, cam->framebuf, count)) {
+		up(&cam->busy_lock);
+		return -EFAULT;
+	}
 
 	if (count != cam->framebuf_size)
 		cam->framebuf_read_start = count;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)