Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp443970iog; Mon, 13 Jun 2022 06:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTU5KAveuHPTEM0W3+94pnQzw/uTN7xPHO6sWwW1BWNjzMoMAa137LPJyrXIoTvn/0LkBP X-Received: by 2002:aa7:d303:0:b0:42d:d192:4c41 with SMTP id p3-20020aa7d303000000b0042dd1924c41mr65964312edq.178.1655125260102; Mon, 13 Jun 2022 06:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125260; cv=none; d=google.com; s=arc-20160816; b=zFXb2narba38pGkNJdF2B/LWOg99GM1HBLztWnWRwWxyLIeE78ZyFDEckxGVMcz00L CWpKS8G7JFh3s16l7w4R18obMGx25oJVzxZSF4Zr7xZe5wE4HIiaNF/RayH2KW3lBdZu pr3bYywOxgyVTRnQfA5y1TCYkNo2h1XaQ/V7dq+5dVKNbe4QuKSqdQGyn3rS3S207CzL Bo3PhMeeiCjNOKhoT/tkfr5Jtdyb0hooLCEQ7QAoRwnR1vO07SL7xbsdat5CqW9qI37j IsC0kv5AMQPthG4cvVd1mNf4rSiLYjvp5vod1+6fO4DYZ75JETtGxGZI3FBG4tZLiVq7 d/8A== 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=FgOBfFnSyS6CPUox9jrBKez8KNEmEPh8d0DRRk63sFE=; b=z08YhUfbXbuBACj1wNifVrI4YMAHSQTRmdfljaS5Qom8L5nF2O8ojlaFZSH6eDmLt5 Vb4RPRQuX8+e6qgiu6SpbHZ38aT0yJOgHlCKma8s4wPqPYPdTVz0PxD6r5MObsWmJr7y xO2IjlbuKib3yPXZdUIpE51YpKb8O+r+hH0pBTc9u3pQRceYi2Bfl3ud1bOQN/0t2kA7 ouObplNGoMNaBiWwOfW6MjdGxokVy+7iCbyveU6Qgqba/NXW0LprBmrqC2vwP/xDkHaL eCgSVPmF+WH0h+Epr9O3E+S+AsDhwH6UijR9v10Vj9ftgJlI4o/cdokYaIcEmrviXVc4 cAZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xtuV+81S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga8-20020a170906b84800b006ff2f915b77si6945883ejb.578.2022.06.13.06.00.30; Mon, 13 Jun 2022 06:01:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xtuV+81S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1350850AbiFMLDS (ORCPT + 99 others); Mon, 13 Jun 2022 07:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350542AbiFMKy5 (ORCPT ); Mon, 13 Jun 2022 06:54:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F3D21255; Mon, 13 Jun 2022 03:31:38 -0700 (PDT) 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 BD181B80EA7; Mon, 13 Jun 2022 10:31:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D113C34114; Mon, 13 Jun 2022 10:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116295; bh=NYXfqZ1HeJVoDcZHWihxR8rS6ByUyPeh1j4e3NSlOOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xtuV+81SmgE1W+0TCWAfp0ZguC0S5XUcbk9C+V9VKSHByaVllpmDuQQIZ0OJcTTzr ru2XS3JNLPo4XqVW+VHcHItSWiyI39Wxxqqqoqdu3JCBiqH/wtzV0oXXXnSaM2Iyb2 5wRUaWgbieHVnDXTwtbbKof5W6rVR7xqPNkh76ls= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Zabel , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 050/411] media: coda: limit frame interval enumeration to supported encoder frame sizes Date: Mon, 13 Jun 2022 12:05:23 +0200 Message-Id: <20220613094930.011374650@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Philipp Zabel [ Upstream commit 67e33dd957880879e785cfea83a3aa24bd5c5577 ] Let VIDIOC_ENUM_FRAMEINTERVALS return -EINVAL if userspace queries frame intervals for frame sizes unsupported by the encoder. Fixes the following v4l2-compliance failure: fail: v4l2-test-formats.cpp(123): found frame intervals for invalid size 47x16 fail: v4l2-test-formats.cpp(282): node->codec_mask & STATEFUL_ENCODER test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL [hverkuil: drop incorrect 'For decoder devices, return -ENOTTY.' in the commit log] Signed-off-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/coda/coda-common.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index 0adc54832657..fb469340634b 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -1192,7 +1192,8 @@ static int coda_enum_frameintervals(struct file *file, void *fh, struct v4l2_frmivalenum *f) { struct coda_ctx *ctx = fh_to_ctx(fh); - int i; + struct coda_q_data *q_data; + const struct coda_codec *codec; if (f->index) return -EINVAL; @@ -1201,12 +1202,19 @@ static int coda_enum_frameintervals(struct file *file, void *fh, if (!ctx->vdoa && f->pixel_format == V4L2_PIX_FMT_YUYV) return -EINVAL; - for (i = 0; i < CODA_MAX_FORMATS; i++) { - if (f->pixel_format == ctx->cvd->src_formats[i] || - f->pixel_format == ctx->cvd->dst_formats[i]) - break; + if (coda_format_normalize_yuv(f->pixel_format) == V4L2_PIX_FMT_YUV420) { + q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); + codec = coda_find_codec(ctx->dev, f->pixel_format, + q_data->fourcc); + } else { + codec = coda_find_codec(ctx->dev, V4L2_PIX_FMT_YUV420, + f->pixel_format); } - if (i == CODA_MAX_FORMATS) + if (!codec) + return -EINVAL; + + if (f->width < MIN_W || f->width > codec->max_w || + f->height < MIN_H || f->height > codec->max_h) return -EINVAL; f->type = V4L2_FRMIVAL_TYPE_CONTINUOUS; -- 2.35.1