> Are you kidding or what ? :

Nope.
 
> > It should get some fixes first:
> 
> > 1. static int w9968cf_allocate_memory(struct w9968cf_device* cam)
> > leaking memory in the error case
> 
> > 2. static int
> > w9968cf_proc_read_main(char* page, char** start, off_t offset,
>                        int count, int* eof, void* data)
> > This line:
> >     for (ptr = list->next; ptr != list; ptr = ptr->next, ncams++);
> > Needs to hold a lock for list traversal. As does the next run in the same
> > function.
> 
> > 3. w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
> > The handling of wait queues looks quite fishy.
> > In particular, it looks racy and how do you know that there's
> > just one active queue?
> 
> > 4. static int
> > w9968cf_start_transfer(struct w9968cf_device* cam)
> > Here:
> >     err = usb_submit_urb(urb, GFP_KERNEL);
> > Race condition. It must come last or you race with the completion handler.
> 
> > 5. static int w9968cf_stop_transfer(struct w9968cf_device* cam)
> > Sleeping with a spinlock held
> 
> Few words:
> 
> I am sorry to say that you didn't  understand _anything_ about the code, I would 
> suggest you to read the code _again_. Above all, IMHO the design is much simpler 
> than other drivers and very efficient when holding spinlocks (At least, Mr. Alan Cox 
> had a look at the _previous_ and already stable version of the driver and approved 
> it (V4l mailing list for more details)).

I read it again.
#1 is actually correct, you are doing the cleanup at some distant place.
 
> I would never write a driver where the code goes sleeping with a spinlock held, LOL
> Also, memory management is ok.

Well, in case you never do that, have you ever wondered how unlinking an URB
synchronously works?
A look at the code:

        spin_lock_irqsave(&cam->urb_lock, lock_flags);
        ^ taking a spinlock
        cam->streaming = 0;
        if (urb->status == -EINPROGRESS)
                if ((err = usb_unlink_urb(urb))) {
                                ^ synchronous unlink - which sleeps
                        spin_unlock_irqrestore(&cam->urb_lock, lock_flags);
                        DBG(1, "Failed to unlink the URB (error n.%d, %s).",
                            err, symbolic(urb_errlist, err))
                        return -EFAULT; /* don't change this value ! */
                }
        spin_unlock_irqrestore(&cam->urb_lock, lock_flags);

        usb_free_urb(urb);
        ^ just in case you wanted to change it to asynchronous.
           bad idea - the urb is freed here

I hope to also further your knowledge about the USB subsystem in
addition to your sense of humor.

        Oliver



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to