This is a note to let you know that I've just added the patch titled usb: gadget: uvc: refactor the check for a valid buffer in the pump worker to the 6.8-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: usb-gadget-uvc-refactor-the-check-for-a-valid-buffer.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 78bda636d615863327acd47b6c3747da513d79c4 Author: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx> Date: Wed Feb 14 00:28:01 2024 +0100 usb: gadget: uvc: refactor the check for a valid buffer in the pump worker [ Upstream commit 5e7ea65daf13a95a6cc63d1377e4c500e4e1340f ] By toggling the condition check for a valid buffer, the else path can be completely avoided. Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20240214-uvc-gadget-cleanup-v1-2-de6d78780459@xxxxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index dd3241fc6939d..dbdd9033c1268 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -594,10 +594,7 @@ static void uvcg_video_pump(struct work_struct *work) */ spin_lock_irqsave(&queue->irqlock, flags); buf = uvcg_queue_head(queue); - - if (buf != NULL) { - video->encode(req, video, buf); - } else { + if (!buf) { /* * Either the queue has been disconnected or no video buffer * available for bulk transfer. Either way, stop processing @@ -607,6 +604,8 @@ static void uvcg_video_pump(struct work_struct *work) break; } + video->encode(req, video, buf); + spin_unlock_irqrestore(&queue->irqlock, flags); spin_lock_irqsave(&video->req_lock, flags);