From: Avichal Rakesh <arakesh@google.com>
To: arakesh@google.com, gregkh@linuxfoundation.org
Cc: dan.scally@ideasonboard.com, etalvala@google.com,
jchowdhary@google.com, laurent.pinchart@ideasonboard.com,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH v2 2/2] usb: gadget: uvc: Remove nested locking
Date: Thu, 4 Jan 2024 13:50:09 -0800 [thread overview]
Message-ID: <20240104215009.2252452-2-arakesh@google.com> (raw)
In-Reply-To: <20240104215009.2252452-1-arakesh@google.com>
When handling error status from uvcg_video_usb_req_queue,
uvc_video_complete currently calls uvcg_queue_cancel with
video->req_lock held. uvcg_queue_cancel internally locks
queue->irqlock, which nests queue->irqlock inside
video->req_lock. This isn't a functional bug at the
moment, but does open up possibilities for ABBA
deadlocks in the future.
This patch fixes the accidental nesting by dropping
video->req_lock before calling uvcg_queue_cancel.
Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
Signed-off-by: Avichal Rakesh <arakesh@google.com>
---
v1 -> v2: Add "Fixes" tag.
drivers/usb/gadget/function/uvc_video.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 7f18dc471be3..dd3241fc6939 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -469,13 +469,15 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
* Put request back in req_free for it to be cleaned
* up later.
*/
- uvcg_queue_cancel(queue, 0);
list_add_tail(&to_queue->list, &video->req_free);
}
} else {
uvc_video_free_request(ureq, ep);
+ ret = 0;
}
spin_unlock_irqrestore(&video->req_lock, flags);
+ if (ret < 0)
+ uvcg_queue_cancel(queue, 0);
}
static int
--
2.43.0.472.g3155946c3a-goog
prev parent reply other threads:[~2024-01-04 21:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 21:07 [PATCH 1/2] usb: gadget: uvc: Fix use are free during STREAMOFF Avichal Rakesh
2023-12-15 21:07 ` [PATCH 2/2] usb: gadget: uvc: Remove nested locking Avichal Rakesh
2024-01-04 14:19 ` Greg KH
2024-01-04 14:19 ` [PATCH 1/2] usb: gadget: uvc: Fix use are free during STREAMOFF Greg KH
2024-01-04 21:56 ` Avichal Rakesh
2024-01-04 21:50 ` [PATCH v2 " Avichal Rakesh
2024-01-04 21:50 ` Avichal Rakesh [this message]
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=20240104215009.2252452-2-arakesh@google.com \
--to=arakesh@google.com \
--cc=dan.scally@ideasonboard.com \
--cc=etalvala@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jchowdhary@google.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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