Hello,

first: I run an Embedded Linux system, so Kernel 2.4.18 shouldn't be changed
by now.

I connect one usb printer and open a usb printer device "/dev/usblp0" and do
some writing into this file. The printer works, but sometimes I get a -1 as
a return from a write call. Then the printer stucks.

So I added some printk into printer.c to see, where this comes from.

These lines are inside "usblp_write":
------
  usblp->writeurb.transfer_buffer_length = (count - writecount) <
USBLP_BUF_SIZE ?
                                                         (count -
writecount) : USBLP_BUF_SIZE;

  if (copy_from_user(usblp->writeurb.transfer_buffer, buffer + writecount,
                                usblp->writeurb.transfer_buffer_length))
  {
        printk("printer.c: Error D = %i\n", -EFAULT);   //@@@ added line!
        printk("           count=%i, writecount=%i, USBLP_BUF_SIZE=%i,
usblp->writeurb.transfer_buffer_length=%i\n", count, writecount,
USBLP_BUF_SIZE, usblp->writeurb.transfer_buffer_length);        //@@@ added
line!
        return -EFAULT;
  }
------

When I get the error the printk writes e.g.:
  printer.c: Error D = -14
             count=1, writecount=45, USBLP_BUF_SIZE=8192,
usblp->writeurb.transfer_buffer_length=8192

Is the buffer length calculated wrong, or doesn't it check memory borders?
Be aware that my system got only few MByte memory. The error occurs
sometimes, not always after printing about 3 to 6 kByte data with some
hundred bytes in buffer.

Another effect I noticed: First I simply tried to close the device after I
got this return -1 and then tried to open it again, but that failed too and
I got a message "MEMORY FAULT" and the system crashed.

If anyone can help me to find a solution, I'd be very happy!

Siegfried.


-------------
HBM - Hottinger Baldwin Messtechnik GmbH
Siegfried Wessler, Dipl.-Ing.
Entwicklung Messverstärker T-V
Im Tiefen See 45, D-64293 Darmstadt
Fon: 06151/803-884, Fax: -524
eMail: [EMAIL PROTECTED]
 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to