Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4463491pxf; Tue, 16 Mar 2021 14:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyDNkIiqttNXKxt5gSEc/c0upYbcTJeg8rAbakhfrGiqoqGZ9oJylSnTNaZXB9lZ3avhXz X-Received: by 2002:aa7:dd4d:: with SMTP id o13mr5237778edw.53.1615929490263; Tue, 16 Mar 2021 14:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615929490; cv=none; d=google.com; s=arc-20160816; b=s5uvF1JaKfUovBG0hVLkh8cAGp8ZivxQd2OgLmM0bf1m7loFfHMYSJ2fyALI6LISj5 QsGBM3PoNPQNxI4E5K4M6JTDZUNPM3YGzbcDtEJU/ArK3di87K66t+PQ/vCF7kjH9Ggr MFkyhDnk+mAZE6pDTbUmELtZ40ZsTt2h8xe5NKinvspXd9arOhKZhtSF5k5FIsmmpk/c FsvcBZbQaT+vUm8QSL0IzoNYx592hqGEBY13ZtEvUJWHdJVcWHXVyv+8KRDC3kXLinF5 EqL1ZqdrAGTfLQKhru3tkwA4VywiwffDoKVps9WfOuliueyjVDRSsr3zjfuPaLYxRNae Jvcg== 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=NN5Cj2ghH9T/Pl2aznH55JCeH97cRnoz9eS6Z+Rn08kZaeNicHzAdAtr4X31nMT4/E VnVh4UiVFtjN/3+ZCS6cEhNhUs5QN8hNW28xalP6q+uIhXzb4/gZEfjwUFWT2d7l3gqU G5rREuWEPYROg4PoKHTf9EohefZiledYryTk1sHnzLWmeVXeShkXIl7upQ0NlJikhzK1 afeD2MRipgxGm6AOAgD7+TXgV3dtmcedZzv2YRk9T0YcRxmEa/I1DyT5QaShLttxwwzz uM/dNhIWrh95VWw6C+XhLfw1Xq7Iz5YgsKFytCZUUkQnEZZnlTcBLcSF7v1Syff/IRvZ Seqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cG0II0bD; 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 cw22si14458402edb.429.2021.03.16.14.17.47; Tue, 16 Mar 2021 14:18:10 -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=cG0II0bD; 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 S239580AbhCPSBR (ORCPT + 99 others); Tue, 16 Mar 2021 14:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239546AbhCPSAL (ORCPT ); Tue, 16 Mar 2021 14:00:11 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEE4FC06174A for ; Tue, 16 Mar 2021 11:00:09 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id e7so22617264edu.10 for ; Tue, 16 Mar 2021 11:00:09 -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=cG0II0bD9BO8wTxnNskixKM4IoZR5lfxEvmdzYjzx1KMvMD9a35KYSXzWCBTmDIsjy 7jPK/a/JoQDMjUnOBznqdt7bJq0ICL7FTNt1gJcvyMxOLasgVXyL8OhiOyU9gdlf3cU6 j2u66UMluSlRdjFIuumABGiJ1Z9H4xq+5zIp0= 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=tFJGEjVyLj2+r16bMmbcVoOcm1vhRj5F5tpEoWdD13wZdvScvX6YySHpA8o0I8Xd9L tlTYvk/1AAK8Ppcvuf+41sqZy11zzJQpHhtW/P/235MD9iuAt0r1FCUWV/KO6WKWRJKo mue5r3W0+YhTfR99SLfY2ghtOBHVU2s5xKfrPegOIwOfpbPKmVai1WNDe00DXvsdE8Yr rhxfNUnQwf4GVYnBqmo9nt9mbih7t7365iDPvh89SCcv3WtgX+XONFq8ZdMrlA+QY4WY GLfh85oJD7eM1uojyKwGEiNhGHfUeGUVMB6Nt62UzA6h8dpW+ngteqa9bt9CihnLoPOi mDvw== X-Gm-Message-State: AOAM530hqPJ+8AJ97VWwtRm77YqZPKbbW7TR3VZCNuscZ92si7v+vD0i hy+wtvOmq2M2DthjwtTxD+YGMg== X-Received: by 2002:a05:6402:17af:: with SMTP id j15mr37619688edy.50.1615917608430; Tue, 16 Mar 2021 11:00:08 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id c19sm10953182edu.20.2021.03.16.11.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 11:00:08 -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, tfiga@chromium.org Cc: Ricardo Ribalda , stable@vger.kernel.org Subject: [PATCH v5 01/13] media: v4l2-ioctl: Fix check_ext_ctrls Date: Tue, 16 Mar 2021 18:59:51 +0100 Message-Id: <20210316180004.1605727-2-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210316180004.1605727-1-ribalda@chromium.org> References: <20210316180004.1605727-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