From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CE143C2B for ; Wed, 29 Nov 2023 02:12:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 8EF8924E29A; Wed, 29 Nov 2023 10:10:55 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 29 Nov 2023 10:10:54 +0800 Received: from [192.168.125.107] (113.72.145.176) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 29 Nov 2023 10:10:53 +0800 Message-ID: Date: Wed, 29 Nov 2023 10:10:50 +0800 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] media: staging: starfive: camss: fix off by one in isp_enum_mbus_code() To: Dan Carpenter , Jack Zhu CC: Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , , , , References: <7d222638-2d19-466d-8dd4-9e1ceb1d46f3@moroto.mountain> Content-Language: en-US From: Changhuang Liang In-Reply-To: <7d222638-2d19-466d-8dd4-9e1ceb1d46f3@moroto.mountain> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag On 2023/11/28 22:40, Dan Carpenter wrote: > These > comparisons should be >=. The formats->fmts[] array is either > a pointer to isp_formats_sink[] or isp_formats_source[] respectively. > > Fixes: e57854628f58 ("media: staging: media: starfive: camss: Add ISP driver") > Signed-off-by: Dan Carpenter Reviewed-by: Changhuang Liang > --- > drivers/staging/media/starfive/camss/stf-isp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c > index 893dbd8cddc8..98d61d71c31b 100644 > --- a/drivers/staging/media/starfive/camss/stf-isp.c > +++ b/drivers/staging/media/starfive/camss/stf-isp.c > @@ -120,7 +120,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, > const struct stf_isp_format_table *formats; > > if (code->pad == STF_ISP_PAD_SINK) { > - if (code->index > ARRAY_SIZE(isp_formats_sink)) > + if (code->index >= ARRAY_SIZE(isp_formats_sink)) > return -EINVAL; > > formats = &isp_dev->formats[SINK_FORMATS_INDEX]; > @@ -128,7 +128,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, > } else { > struct v4l2_mbus_framefmt *sink_fmt; > > - if (code->index > ARRAY_SIZE(isp_formats_source)) > + if (code->index >= ARRAY_SIZE(isp_formats_source)) > return -EINVAL; > > sink_fmt = v4l2_subdev_state_get_format(state,