mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Piyush Mehta <piyush.mehta@amd.com>
To: <laurent.pinchart@ideasonboard.com>,
	<dan.scally@ideasonboard.com>, <michal.simek@amd.com>,
	<gregkh@linuxfoundation.org>
Cc: <siva.durga.prasad.paladugu@amd.com>,
	<radhey.shyam.pandey@amd.com>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Piyush Mehta <piyush.mehta@amd.com>
Subject: [PATCH] usb: gadget: uvc_video: unlock before submitting a request to ep
Date: Thu, 2 Nov 2023 12:41:38 +0530	[thread overview]
Message-ID: <20231102071138.828126-1-piyush.mehta@amd.com> (raw)

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: Piyush Mehta <piyush.mehta@amd.com>
---
 drivers/usb/gadget/function/uvc_video.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 91af3b1ef0d4..0a5d9ac145e7 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -460,11 +460,12 @@ static void uvcg_video_pump(struct work_struct *work)
 			req->no_interrupt = 1;
 		}
 
-		/* Queue the USB request */
-		ret = uvcg_video_ep_queue(video, req);
 		spin_unlock_irqrestore(&queue->irqlock, flags);
 
+		/* Queue the USB request */
+		ret = uvcg_video_ep_queue(video, req);
 		if (ret < 0) {
+			usb_ep_set_halt(video->ep);
 			uvcg_queue_cancel(queue, 0);
 			break;
 		}
-- 
2.25.1


             reply	other threads:[~2023-11-02  7:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02  7:11 Piyush Mehta [this message]
2023-11-02  9:05 ` Sergey Shtylyov
2023-11-02 12:00 ` Dan Scally
2023-11-08 11:48   ` Kuen-Han Tsai
2023-11-08 14:19     ` Dan Scally
2023-11-16  9:28     ` Dan Scally
2023-11-17  1:45       ` Thinh Nguyen
2023-11-17  3:28         ` Thinh Nguyen
2024-01-10  9:14           ` Pandey, Radhey Shyam
2024-01-11  1:21             ` Thinh Nguyen
2024-01-19  2:15             ` Thinh Nguyen
2024-01-29 10:08               ` Pandey, Radhey Shyam
2024-05-14  7:04                 ` Pandey, Radhey Shyam
2024-05-17  2:42                   ` Kuen-Han Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231102071138.828126-1-piyush.mehta@amd.com \
    --to=piyush.mehta@amd.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=siva.durga.prasad.paladugu@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®