patch-2.4.21 linux-2.4.21/drivers/usb/mdc800.c

Next file: linux-2.4.21/drivers/usb/ov511.c
Previous file: linux-2.4.21/drivers/usb/konicawc.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/drivers/usb/mdc800.c linux-2.4.21/drivers/usb/mdc800.c
@@ -726,7 +726,7 @@
 		else
 		{
 			/* memcpy Bytes */
-			memcpy (ptr, &mdc800->out [mdc800->out_ptr], sts);
+			copy_to_user(ptr, &mdc800->out [mdc800->out_ptr], sts);
 			ptr+=sts;
 			left-=sts;
 			mdc800->out_ptr+=sts;
@@ -763,14 +763,21 @@
 
 	while (i<len)
 	{
+		unsigned char c;
 		if (signal_pending (current)) 
 		{
 			up (&mdc800->io_lock);
 			return -EINTR;
 		}
+		
+		if(get_user(c, buf+i))
+		{
+			up(&mdc800->io_lock);
+			return -EFAULT;
+		}
 
 		/* check for command start */
-		if (buf [i] == (char) 0x55)
+		if (c == 0x55)
 		{
 			mdc800->in_count=0;
 			mdc800->out_count=0;
@@ -781,12 +788,11 @@
 		/* save command byte */
 		if (mdc800->in_count < 8)
 		{
-			mdc800->in[mdc800->in_count]=buf[i];
+			mdc800->in[mdc800->in_count] = c;
 			mdc800->in_count++;
 		}
 		else
 		{
-			err ("Command is to long !\n");
 			up (&mdc800->io_lock);
 			return -EIO;
 		}
@@ -861,8 +867,8 @@
 							return -EIO;
 						}
 
-						/* Write dummy data, (this is ugly but part of the USB Protokoll */
-						/* if you use endpoint 1 as bulk and not as irq */
+						/* Write dummy data, (this is ugly but part of the USB Protocol */
+						/* if you use endpoint 1 as bulk and not as irq) */
 						memcpy (mdc800->out, mdc800->camera_response,8);
 
 						/* This is the interpreted answer */

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