Showing error 527

User: Jiri Slaby
Error type: Calling function from invalid context
Error type description: Some function is called at inappropriate place like sleep inside critical sections or interrupt handlers
File location: drivers/usb/gadget/printer.c
Line in file: 609
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:19:02 UTC


Source:

 579
 580        bytes_copied = 0;
 581        current_rx_req = dev->current_rx_req;
 582        current_rx_bytes = dev->current_rx_bytes;
 583        current_rx_buf = dev->current_rx_buf;
 584        dev->current_rx_req = NULL;
 585        dev->current_rx_bytes = 0;
 586        dev->current_rx_buf = NULL;
 587
 588        /* Check if there is any data in the read buffers. Please note that
 589         * current_rx_bytes is the number of bytes in the current rx buffer.
 590         * If it is zero then check if there are any other rx_buffers that
 591         * are on the completed list. We are only out of data if all rx
 592         * buffers are empty.
 593         */
 594        if ((current_rx_bytes == 0) &&
 595                        (likely(list_empty(&dev->rx_buffers)))) {
 596                /* Turn interrupts back on before sleeping. */
 597                spin_unlock_irqrestore(&dev->lock, flags);
 598
 599                /*
 600                 * If no data is available check if this is a NON-Blocking
 601                 * call or not.
 602                 */
 603                if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) {
 604                        spin_unlock(&dev->lock_printer_io);
 605                        return -EAGAIN;
 606                }
 607
 608                /* Sleep until data is available */
 609                wait_event_interruptible(dev->rx_wait,
 610                                (likely(!list_empty(&dev->rx_buffers))));
 611                spin_lock_irqsave(&dev->lock, flags);
 612        }
 613
 614        /* We have data to return then copy it to the caller's buffer.*/
 615        while ((current_rx_bytes || likely(!list_empty(&dev->rx_buffers)))
 616                        && len) {
 617                if (current_rx_bytes == 0) {
 618                        req = container_of(dev->rx_buffers.next,
 619                                        struct usb_request, list);
Show full sources