From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 274E425B68E; Tue, 11 Mar 2025 15:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741707660; cv=none; b=X/RRNL8anWX/rK8trC7rUKjD37ST3dqw9J61DZg4sKwpFulVnaUWCMNAflW6jO9FEZOLZYTb65ZigwGxisc9St8lpcF8fWafaF4OoOydjfh1VhcQaGvnj1USV68FDzx7KW6sMtAXcsVvZlkuoju1Mek7Z5aXkhVr1igYNeUf+Ck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741707660; c=relaxed/simple; bh=LM9qSgAj+xB+OE94B++WvtSxVuwkXNyRAjXBOVk4zUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lP7KmdQi4J8nr+7pRvpw3BSEycHQ1E0u/52qyQfZn+6A+abL3bDg1Z7IBBdugUqgQu3s0dDcQ9hS0m8N4/2r1c6Gop5VT+ffxuoM5L8QBxsQBGITJR/eaIawh3MDY43vLBQl7AMbVVJOk9QrV324QK/LLSkdoRg/rm8xlUQh3oA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jz2nbEf0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jz2nbEf0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44E45C4CEE9; Tue, 11 Mar 2025 15:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741707659; bh=LM9qSgAj+xB+OE94B++WvtSxVuwkXNyRAjXBOVk4zUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jz2nbEf0aGkjIIHWNHnSo0zAI6ECJPUUglRqEEW9Jfu+uFe5P+P8rThYwdZ8U9oWe E8jUz0B1QPEsrWpd3DKiNeXvj1ilfcGnczyTC9cQgjN695jDa92cmP7UJNElBeh+zb biJ3BCOla2w8Gf5PYoH0GztqMI1pziUxcYqV9weU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hans de Goede , Laurent Pinchart , Ricardo Ribalda , Mauro Carvalho Chehab Subject: [PATCH 5.10 449/462] media: uvcvideo: Only save async fh if success Date: Tue, 11 Mar 2025 16:01:55 +0100 Message-ID: <20250311145816.061138164@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311145758.343076290@linuxfoundation.org> References: <20250311145758.343076290@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ricardo Ribalda commit d9fecd096f67a4469536e040a8a10bbfb665918b upstream. Now we keep a reference to the active fh for any call to uvc_ctrl_set, regardless if it is an actual set or if it is a just a try or if the device refused the operation. We should only keep the file handle if the device actually accepted applying the operation. Cc: stable@vger.kernel.org Fixes: e5225c820c05 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives") Suggested-by: Hans de Goede Reviewed-by: Hans de Goede Reviewed-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda Link: https://lore.kernel.org/r/20241203-uvc-fix-async-v6-1-26c867231118@chromium.org Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- --- drivers/media/usb/uvc/uvc_ctrl.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1526,7 +1526,9 @@ int uvc_ctrl_begin(struct uvc_video_chai } static int uvc_ctrl_commit_entity(struct uvc_device *dev, - struct uvc_entity *entity, int rollback) + struct uvc_fh *handle, + struct uvc_entity *entity, + int rollback) { struct uvc_control *ctrl; unsigned int i; @@ -1570,6 +1572,10 @@ static int uvc_ctrl_commit_entity(struct if (ret < 0) return ret; + + if (!rollback && handle && + ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS) + ctrl->handle = handle; } return 0; @@ -1585,7 +1591,8 @@ int __uvc_ctrl_commit(struct uvc_fh *han /* Find the control. */ list_for_each_entry(entity, &chain->entities, chain) { - ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback); + ret = uvc_ctrl_commit_entity(chain->dev, handle, entity, + rollback); if (ret < 0) goto done; } @@ -1709,9 +1716,6 @@ int uvc_ctrl_set(struct uvc_fh *handle, mapping->set(mapping, value, uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT)); - if (ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS) - ctrl->handle = handle; - ctrl->dirty = 1; ctrl->modified = 1; return 0; @@ -2040,7 +2044,7 @@ int uvc_ctrl_restore_values(struct uvc_d ctrl->dirty = 1; } - ret = uvc_ctrl_commit_entity(dev, entity, 0); + ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0); if (ret < 0) return ret; }