Skip to content

Commit

Permalink
usb: gadget: uvc_video: unlock before submitting a request to ep
Browse files Browse the repository at this point in the history
There could be chances where the usb_ep_queue() could fail and trigger
complete() handler with error status. In this case, if usb_ep_queue()
is called with lock held and the triggered complete() handler is waiting
for the same lock to be cleared could result in a deadlock situation and
could result in system hang. To aviod this scenerio, call usb_ep_queue()
with lock removed. This patch does the same.

Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
State: pending
  • Loading branch information
Anurag Kumar Vulisha authored and Michal Simek committed Apr 16, 2020
1 parent be02dfe commit f72d142
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/usb/gadget/function/uvc_video.c
Expand Up @@ -332,11 +332,15 @@ int uvcg_video_pump(struct uvc_video *video)

video->encode(req, video, buf);

spin_unlock_irqrestore(&queue->irqlock, flags);

/* Queue the USB request */
ret = uvcg_video_ep_queue(video, req);
spin_unlock_irqrestore(&queue->irqlock, flags);

if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
uvcg_queue_cancel(queue, 0);
break;
}
Expand Down

0 comments on commit f72d142

Please sign in to comment.