Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3599812pxb; Mon, 24 Jan 2022 13:12:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzORhxJcbqR6hZMP9UpipcZh09qqCy0TXied2X8dD3Avkh6c8kjImxfWjtAZG35lmacx16q X-Received: by 2002:a63:eb06:: with SMTP id t6mr12957074pgh.366.1643058774065; Mon, 24 Jan 2022 13:12:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058774; cv=none; d=google.com; s=arc-20160816; b=twmIERHsxWr/Phuhk1tVdIAMUhj4bD2t2woBWaS9tNTegjypWh+Za1U3lcBq5jEIEY n9R+3ELsmshgnP5qD4Knka6Q6K0WlBZusOAZNjB7iLHKN5hWx3uwPju6XY5tcjDyL5NJ X7C8tHi+V0xwWKqk6rtnYm7zNlKKjhEB5PZO8v4QT+wej/V0ugbhCNmUXaThDvwtK4aM w9OLxLYjZlsulaThC940Cf0GbRlMqd1K12hA9EjrCVu+aL0bJ2uzL9SHstHlSIabRglV 2EJnBfVDdn4XrChkylWJufaBprXf5PiAdUiZ9U4clCbJqW/7TeE9CIY/v6AuK0TNVlna rSPg== 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=2swWOxK7NrH6cqVncjpTMPdA0JTeBJr2+QbTxgBXSto=; b=jKXFo8rb5ZyoR3Pbz3TcbgpXkNZxpQOysL99gIFLXaZutlblfymomUCyE8FYi6ifZI c+e796/e5pxfwxtLfNAX5LrdAd+ot/IqTVhnrUrCSU+vKM0MMz4y3nxD1dCLLOcU6qmk 3ZKOL8f7Fq4BDwOMv4NcQqGqCPt+UcGcchdJFufvAkLFKh+PzWbsq8qmzLEL9n6wNzf8 5ra3unf835Vi1J+8rhdFRAQxkJAHK93vdTDyiW8QT8rENfHKVB7lN6OBekZp0t8ZCj1t dkAlzjnNzgLa90I+alx8uRf+2F27kBqBW+fiP0dbwkhPf0Cf/fzG7RhFTfTLyw60bjvd Vgjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y5QsaEpv; 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 b16si1554676pgs.406.2022.01.24.13.12.41; Mon, 24 Jan 2022 13:12:54 -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=y5QsaEpv; 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 S1386780AbiAXUf6 (ORCPT + 99 others); Mon, 24 Jan 2022 15:35:58 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:52354 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354958AbiAXUNM (ORCPT ); Mon, 24 Jan 2022 15:13:12 -0500 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 66583B8122A; Mon, 24 Jan 2022 20:13:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C82FAC340E5; Mon, 24 Jan 2022 20:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055188; bh=UItwY6rAE8WLkBjLQX6eFvj3n9nE9k5dSFfzYfrYkkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y5QsaEpvzeONB9twk06OYW8cVXJ5bmXbiwL7Ya6AWdkX/Uo6yZ8osE6JLLKTfuYs4 u63pfQXRS12UiZILdXuPCNdbb6DvxFxK4zwXBHiqY6eZY1T5FzfKXkwBZlM4mdu6fJ gQO7cfFEBGpPviqvxhzHF0MGuihfdQAhRK1tv/tg= 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.15 042/846] media: v4l2-ioctl.c: readbuffers depends on V4L2_CAP_READWRITE Date: Mon, 24 Jan 2022 19:32:39 +0100 Message-Id: <20220124184102.400071146@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 @@ -2088,6 +2088,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); @@ -2099,7 +2100,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);