X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fserial%2Fempeg.c;h=251a50fdab8670ffe12182a48d266fbe2f5b72e2;hb=9e1bf581d67d87a1d7fc0ea500729e3a03643a26;hp=4d46394f351b184bd778bc5aa3d4c5a9c6405ce4;hpb=8d40237c730b8be87c1b80a5d96b9c603fefa829;p=linux-2.6.git diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 4d46394f3..251a50fda 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -81,6 +81,7 @@ static int debug; static int empeg_open (struct usb_serial_port *port, struct file *filp); static void empeg_close (struct usb_serial_port *port, struct file *filp); static int empeg_write (struct usb_serial_port *port, + int from_user, const unsigned char *buf, int count); static int empeg_write_room (struct usb_serial_port *port); @@ -184,13 +185,13 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp) dbg("%s - port %d", __FUNCTION__, port->number); /* shutdown our bulk read */ - usb_kill_urb(port->read_urb); + usb_unlink_urb (port->read_urb); /* Uncomment the following line if you want to see some statistics in your syslog */ /* dev_info (&port->dev, "Bytes In = %d Bytes Out = %d\n", bytes_in, bytes_out); */ } -static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count) +static int empeg_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct urb *urb; @@ -234,7 +235,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); - memcpy (urb->transfer_buffer, current_position, transfer_size); + if (from_user) { + if (copy_from_user (urb->transfer_buffer, current_position, transfer_size)) { + bytes_sent = -EFAULT; + break; + } + } else { + memcpy (urb->transfer_buffer, current_position, transfer_size); + } usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, urb->transfer_buffer); @@ -398,7 +406,7 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) static void empeg_throttle (struct usb_serial_port *port) { dbg("%s - port %d", __FUNCTION__, port->number); - usb_kill_urb(port->read_urb); + usb_unlink_urb (port->read_urb); } @@ -571,10 +579,10 @@ static void __exit empeg_exit (void) for (i = 0; i < NUM_URBS; ++i) { if (write_urb_pool[i]) { - /* FIXME - uncomment the following usb_kill_urb call when + /* FIXME - uncomment the following usb_unlink_urb call when * the host controllers get fixed to set urb->dev = NULL after * the urb is finished. Otherwise this call oopses. */ - /* usb_kill_urb(write_urb_pool[i]); */ + /* usb_unlink_urb(write_urb_pool[i]); */ if (write_urb_pool[i]->transfer_buffer) kfree(write_urb_pool[i]->transfer_buffer); usb_free_urb (write_urb_pool[i]);