Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3535435pxf; Mon, 15 Mar 2021 11:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMgPBZvXCwn2Y5uUM7eiEbICm268HTGU2hHz/zslHVZCa/5jrxBjHAQIAEikgo+iXg5l0k X-Received: by 2002:a17:906:4d44:: with SMTP id b4mr25318339ejv.338.1615833873757; Mon, 15 Mar 2021 11:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833873; cv=none; d=google.com; s=arc-20160816; b=Qr6LpdtX9IWSsVcCPx0TpedR3raKk278cVO/e8hUj+MsvoNI75w6U7Dv6ydd6rSLvU LN/tN6HniGSgNPwwfDVVrwvJimXdAELT+HpnSVu2Kkh7vJ36fORP9VEu6vs+BD2YUNDa yEGsgCETEP6hXHg1roFeMu9qcjCx26+AwXXniO/WAGfkAcF7E3tSLYFynMwR/Rr5fABb Xuv3uNKWdpyWpEYbDfgqo6HTWU+LkJivraUyFjMq4iTyYBsqI2103TohnKpdH0JN/6nb wsSZsAPNsIDJzyz4nPd3alQ0zmSNDzj8S5WzqxdD5SZVkXrM9By62UcFBqjhxN+HXFr2 +Pcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DgS4OPGpMnlY/AXfZW8QgtbwbGQ3UnwEJWQevK1FyQM=; b=fm5jiHU5bfJZtFeEw8OmC+yNc3xC0qALZqvHufvEa1BzvItEBWZQeroJOffBaS5RLp 18JtEQ2EJYNq9N8bfMm8O6idancXns+Dz2+QLWEd7PAeBa9MxrUGOLSnCo+i56VW1b3H 0BbsEcYB8yQRquR7YK7ngHedK70D4IhmRgmRGnF44RD/b6XSWijPc939TPLoW8+KrEG+ 3bjZ3WBUBQnuprJmKTRLJhYzb23wvr3HdP++BXiT/XUNZw54DOIJT3K4ZXNwknN6foQ8 NEXUYfF6ecgM0Vx+FBnz8dzMPHkCJu6HwJ+IrLVVutaz7Ufj68iBBcTGOhM7+9foBGRe 8Ptg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Al7Au5qr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e2si11272587ejd.17.2021.03.15.11.44.10; Mon, 15 Mar 2021 11:44:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Al7Au5qr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233952AbhCORgh (ORCPT + 99 others); Mon, 15 Mar 2021 13:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233145AbhCORgN (ORCPT ); Mon, 15 Mar 2021 13:36:13 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87909C06174A for ; Mon, 15 Mar 2021 10:36:13 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id mm21so67601870ejb.12 for ; Mon, 15 Mar 2021 10:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DgS4OPGpMnlY/AXfZW8QgtbwbGQ3UnwEJWQevK1FyQM=; b=Al7Au5qrWKDUWWxWszyg+RCKYoNVfZF0Ls3oN/2uJW2qijirbLB8Ls9c9al9GH1PqS XJTiZ5qLKkjlQ57tROZSdvEMFl1PNE2LwXTN8sVWHICg/4NtoVbWGpHGto7aLGg5ebgm /GdQT2pCbd3tce+FV57gOZON15GPsKK6oUI/s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DgS4OPGpMnlY/AXfZW8QgtbwbGQ3UnwEJWQevK1FyQM=; b=RZwcixVvewGz6ApuQJx9cy1d+A99Wkqgc3Jy9C3hFdqeY+kkbkTmA7Mau9Auw7kaAX qTMLUhC3R+uev8KTOWkaAZNOgNKdPhwDZR9f+C6e2bruI9WurJjOAj70rl4+2+vABKn/ 4EFCj7YzWEuktCmHZTkSkDD9iBPeVl+7g8ZuKh/SFHMF+30HEVG8flBE2hBIUeLZEaAH oHxcMJ5Lx+5cO6nWuY4fvaT9n4jVtCahP+rtXWSThKow1Ey8ZDSsgC0wtxyg2OLWXfTJ kZGkN82t1i9e76fDNrnR9UR0IQtMhbkPwDU8MhobadrNGidCpscNN1I3YNcs6isdFDU2 /SOg== X-Gm-Message-State: AOAM5326AfEsKhtPTOCodGYaPSbNxn/UKMLYfMHIFK9AwNpn0dzR+Zbz S2rG4IZ9nLZvasLqqgCCtee3kQ== X-Received: by 2002:a17:906:5acd:: with SMTP id x13mr24713291ejs.211.1615829772215; Mon, 15 Mar 2021 10:36:12 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id a3sm8109239ejv.40.2021.03.15.10.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 10:36:12 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda , stable@vger.kernel.org Subject: [PATCH v4 01/11] media: v4l2-ioctl: Fix check_ext_ctrls Date: Mon, 15 Mar 2021 18:35:59 +0100 Message-Id: <20210315173609.1547857-2-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210315173609.1547857-1-ribalda@chromium.org> References: <20210315173609.1547857-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers that do not use the ctrl-framework use this function instead. - Return error when handling of REQUEST_VAL. - Do not check for multiple classes when getting the DEF_VAL. Fixes v4l2-compliance: Control ioctls (Input 0): fail: v4l2-test-controls.cpp(813): doioctl(node, VIDIOC_G_EXT_CTRLS, &ctrls) test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL Cc: stable@vger.kernel.org Fixes: 6fa6f831f095 ("media: v4l2-ctrls: add core request support") Suggested-by: Hans Verkuil Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-ioctl.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 31d1342e61e8..9406e90ff805 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -917,15 +917,24 @@ static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) for (i = 0; i < c->count; i++) c->controls[i].reserved2[0] = 0; - /* V4L2_CID_PRIVATE_BASE cannot be used as control class - when using extended controls. - Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL - is it allowed for backwards compatibility. - */ - if (!allow_priv && c->which == V4L2_CID_PRIVATE_BASE) - return 0; - if (!c->which) + switch (c->which) { + case V4L2_CID_PRIVATE_BASE: + /* + * V4L2_CID_PRIVATE_BASE cannot be used as control class + * when using extended controls. + * Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL + * is it allowed for backwards compatibility. + */ + if (!allow_priv) + return 0; + break; + case V4L2_CTRL_WHICH_DEF_VAL: + case V4L2_CTRL_WHICH_CUR_VAL: return 1; + case V4L2_CTRL_WHICH_REQUEST_VAL: + return 0; + } + /* Check that all controls are from the same control class. */ for (i = 0; i < c->count; i++) { if (V4L2_CTRL_ID2WHICH(c->controls[i].id) != c->which) { -- 2.31.0.rc2.261.g7f71774620-goog