Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3690571pxb; Mon, 24 Jan 2022 15:28:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPC+QXguwEIaXz6Z0hNjNfA3I3y6FAWd8vniSKNolF10IkmEWW5GNDkx6ZhDF4wP8sJv4x X-Received: by 2002:a17:903:2049:b0:14b:61:b19e with SMTP id q9-20020a170903204900b0014b0061b19emr16114780pla.20.1643066911930; Mon, 24 Jan 2022 15:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066911; cv=none; d=google.com; s=arc-20160816; b=wE008pVFPqS7P9/nHxejBuddJ/r5k14pKnVhkR7t5KlRRdJdCxARLpCiwhPEoCM8Mr yXYCxdVDA/9h19j4sdKu1+dFslScwNt9Y4pZsXSAsfEbx7tOJyR0pjDAyno3fhDNbavp Pzvlb98B8tVWVcVzx9Ieh/sUZyMMRI3jlwCp9J1qwlhOIrEI5o4ZXmtgE+d2d9whZKjQ 7/hBShJ7VEaS4MHLFY/0o6yNtfk/tqfpzxI5c9zfyz5XQprLg72QICDC9cCiqNpAqqbJ BJP3VarQYS31AurHn/ESa+ELgWzVIn3n5KXQiJFavFLzwk+rcirFu3UitygRihQV9n3j sBMA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aObn4aBFwNpF9PEi5wCJxL2zcQ6iKK6Pq9wa4l7QHKc=; b=agL55mbDoDNgPjysOjIGOY9PLUuvYSH/cPcoUZla0k9lYOycsIr9ikRc53eD3onHi0 BiBvKShePGkBgk6mD5pE6TwQSS8pHqQ13IVqe7F2yfNMEM3842n5B1POKrbeLAU7OxNu okCgRLmbfndwWWvtBNJ/h2fiOiqjwTvfWPBDHImbxzuaLlH7S2s1MRpi/JC19Fc+il4T giY0jNGWQ00Ni9V9NbShIVP/2hKPAOa88a3CV8TOckv3PQG82vPSvDkXN/L37kM/oSrj 6/TSUrmpazT44B0s0yEvoZ5iUHEp8SQWx2fSFos/nCvu7zsihVuinVUNJ823LZ/DzDOe cdYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WY8KbOi7; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j125si16603643pfd.42.2022.01.24.15.28.20; Mon, 24 Jan 2022 15:28:31 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=WY8KbOi7; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1848048AbiAXXVi (ORCPT + 99 others); Mon, 24 Jan 2022 18:21:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1586976AbiAXW1f (ORCPT ); Mon, 24 Jan 2022 17:27:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9549CC0E5303; Mon, 24 Jan 2022 12:54:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5BEF1B8122A; Mon, 24 Jan 2022 20:54:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F3D2C340E5; Mon, 24 Jan 2022 20:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057684; bh=PawTXDQsYbpchk/L0u350gN2qSbXLyEo+9hwZYC02lQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WY8KbOi71uuiPkVPjnA6DTBdv7HZnu5rbhNylLbxDEjzSyfZwabvIU6qwPy4Rihzz /W2ZD9v8NJ1SQAMIJpzc/Na+E+ggWcjXMrHPUUkm3OOegRHa4Z+hIlqvr3b1bpN06z HplnLwGwRO/GIEh0rpN4T3GOVm3PhxXJTi31Ed9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.16 0044/1039] media: v4l2-ioctl.c: readbuffers depends on V4L2_CAP_READWRITE Date: Mon, 24 Jan 2022 19:30:33 +0100 Message-Id: <20220124184126.619934899@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil commit cd9d9377ed235b294a492a094e1666178a5e78fd upstream. If V4L2_CAP_READWRITE is not set, then readbuffers must be set to 0, otherwise v4l2-compliance will complain. A note on the Fixes tag below: this patch does not really fix that commit, but it can be applied from that commit onwards. For older code there is no guarantee that device_caps is set, so even though this patch would apply, it will not work reliably. Signed-off-by: Hans Verkuil Fixes: 049e684f2de9 (media: v4l2-dev: fix WARN_ON(!vdev->device_caps)) Cc: Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2090,6 +2090,7 @@ static int v4l_prepare_buf(const struct static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { + struct video_device *vfd = video_devdata(file); struct v4l2_streamparm *p = arg; v4l2_std_id std; int ret = check_fmt(file, p->type); @@ -2101,7 +2102,8 @@ static int v4l_g_parm(const struct v4l2_ if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) return -EINVAL; - p->parm.capture.readbuffers = 2; + if (vfd->device_caps & V4L2_CAP_READWRITE) + p->parm.capture.readbuffers = 2; ret = ops->vidioc_g_std(file, fh, &std); if (ret == 0) v4l2_video_std_frame_period(std, &p->parm.capture.timeperframe);