USB: Remove races in devio.c
authorHuajun Li <huajun.li.lee@gmail.com>
Fri, 18 May 2012 12:12:51 +0000 (20:12 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 30 May 2012 23:43:45 +0000 (00:43 +0100)
commit8903f762151994729c79eae3b5afc9fc399be905
tree5f5ca4c47c8dfc6131c57f1232aad99962d81ec7
parentf561ae3b578093ffffcb6110d4e33500059c908f
USB: Remove races in devio.c

commit 4e09dcf20f7b5358615514c2ec8584b248ab8874 upstream.

There exist races in devio.c, below is one case,
and there are similar races in destroy_async()
and proc_unlinkurb().  Remove these races.

 cancel_bulk_urbs()        async_completed()
-------------------                -----------------------
 spin_unlock(&ps->lock);

                           list_move_tail(&as->asynclist,
                    &ps->async_completed);

                           wake_up(&ps->wait);

                           Lead to free_async() be triggered,
                           then urb and 'as' will be freed.

 usb_unlink_urb(as->urb);
 ===> refer to the freed 'as'

Signed-off-by: Huajun Li <huajun.li.lee@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Oncaphillis <oncaphillis@snafu.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/core/devio.c