Received: by 10.213.65.68 with SMTP id h4csp1356873imn; Wed, 21 Mar 2018 08:44:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELu3nKs6XLjuu1IK9318zQbzso9zWDGCM8rFOXYMBhvtV2B6m1htkxyuazSDeFajzSoMylGL X-Received: by 10.101.69.133 with SMTP id o5mr15237348pgq.156.1521647097692; Wed, 21 Mar 2018 08:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521647097; cv=none; d=google.com; s=arc-20160816; b=oVQbcsaXQObe37O8S4xnlQgR5VczfYDDxkVAPuRf6biZc7N6Tjjeg+dEHSBEuZtMCJ Hy9MuNtSPxeqCdb9EXtCoEkYTO2qQ93QebvoqS5lJ4dRJSUWrHH8lf/vMbWtrHiYbZtF I5Qt7EKyTLDwUaAQw5QmlD+MxxLCVgt0wQ7hDz0wrdQOciMK12o9ixQYb6zjup/G8v/n 4IDpMiGG7tcROKkhQ1cOmvLIq17pbuNssapBJE2BOOBoC5pPLz+DOx1LbiX20il+6wf+ umyc+KdKGZcTe9Gy5wq86GVF8fjTaCQSP1CPgHlMFMXc4jaHQIEahnm6yUeTjSUZbf1S TGZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=O83cqtngRby1w+QfiMh+73rk6lvluTuSaU44o8a5/+4=; b=FH5UcPtvZWrLb3g/FAjHEj2E3WMJnc4UyFj7+XctJV7TsWfMuzlqGa2L0IEHTy0Fpw lUCuzNcoqy+jnyC2pYgzIc1wt0nOJbG1BzbSWHdzw4GAaysijDR7bfeJayXniI0XLMhw iwDUMGk5tRjQmHh64kPMm/H46YN727232f4yoSLMYU9cFsij2gDpoRmrgIb/cWDFUgiP rucW6A+rPMdelBLvHSzE3ktP/vwFBjNt9w+U6yMBAXV97pYAZDSuua/ZXo7pPYL72dYQ a+cYB/5TKcy1EJEuMzaQQHU76fa4koUG29hziFZ5KSJwecMoK/SmB4ZhhLTOqCr10XFZ X9FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=amZcwpsU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si3149784pfh.84.2018.03.21.08.44.43; Wed, 21 Mar 2018 08:44:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=amZcwpsU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649AbeCUPn2 (ORCPT + 99 others); Wed, 21 Mar 2018 11:43:28 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:40777 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbeCUPnO (ORCPT ); Wed, 21 Mar 2018 11:43:14 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 3B6AE20064; Wed, 21 Mar 2018 16:40:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1521646851; bh=c0zdelX6JEaot0vAaYPFQxBAfj6HTah1tO74bscT4RM=; h=From:To:Cc:Subject:Date:From; b=amZcwpsUR14ldSBKt6YKWkHcCt7K1F2uH03jZJzUoQKfZ9nHBi3gVCKltksYxhjov r7Y4lX/84N1VThVzsuJNYqSrLRhfUTy51G+fJmpsDgDgwxNDOZ7K1Y6D+R2F1BcPEp yaSj5fJP+cRcgyyCVDrU1iPEDo3d/R858nBNw9TU= From: Kieran Bingham To: linux-media@vger.kernel.org, Laurent Pinchart , Edgar Thier Cc: Kieran Bingham , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] media: uvcvideo: Prevent setting unavailable flags Date: Wed, 21 Mar 2018 15:43:08 +0000 Message-Id: <1521646988-803-1-git-send-email-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The addition of an extra operation to use the GET_INFO command overwrites all existing flags from the uvc_ctrls table. This includes setting all controls as supporting GET_MIN, GET_MAX, GET_RES, and GET_DEF regardless of whether they do or not. Move the initialisation of these control capabilities directly to the uvc_ctrl_fill_xu_info() call where they were originally located in that use case, and ensure that the new functionality in uvc_ctrl_get_flags() will only set flags based on their reported capability from the GET_INFO call. Fixes: 859086ae3636 ("media: uvcvideo: Apply flags from device to actual properties") Signed-off-by: Kieran Bingham --- drivers/media/usb/uvc/uvc_ctrl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 1daf444371be..4042cbdb721b 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1607,14 +1607,12 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev, ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum, info->selector, data, 1); if (!ret) - info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX - | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF - | (data[0] & UVC_CONTROL_CAP_GET ? - UVC_CTRL_FLAG_GET_CUR : 0) - | (data[0] & UVC_CONTROL_CAP_SET ? - UVC_CTRL_FLAG_SET_CUR : 0) - | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ? - UVC_CTRL_FLAG_AUTO_UPDATE : 0); + info->flags |= (data[0] & UVC_CONTROL_CAP_GET ? + UVC_CTRL_FLAG_GET_CUR : 0) + | (data[0] & UVC_CONTROL_CAP_SET ? + UVC_CTRL_FLAG_SET_CUR : 0) + | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ? + UVC_CTRL_FLAG_AUTO_UPDATE : 0); kfree(data); return ret; @@ -1689,6 +1687,9 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev, info->size = le16_to_cpup((__le16 *)data); + info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX + | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF; + ret = uvc_ctrl_get_flags(dev, ctrl, info); if (ret < 0) { uvc_trace(UVC_TRACE_CONTROL, -- 2.7.4