From patchwork Tue Nov 28 14:40:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 170824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3969844vqx; Tue, 28 Nov 2023 06:40:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEofVdmwCSGuMmrWOio/OjMTEF/k2Z68yQAFcXSWZyqViYfZFWj7gedJVzfYiY8+UzhSY9t X-Received: by 2002:a17:90a:191a:b0:285:6565:fd20 with SMTP id 26-20020a17090a191a00b002856565fd20mr12612401pjg.22.1701182426011; Tue, 28 Nov 2023 06:40:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701182425; cv=none; d=google.com; s=arc-20160816; b=n91ONa5nWLOj7V82/aUyTqDCQVVD2ZhDhBa7f3iabntv3vfcue6If753LcGk3+Ipn2 siSRjByNGhkifa+zuj7FKjU5udOHsGRcYdG5nutKq+EeRgqg/suxcEV4JBASuekxxzju m+NKFkQbeWNSkrwmpU2o+x+bxGcm6zJAvZDu2KpS1i4pvgc4NJiEM4U/Kfgwh1lbpJ4W zTqxF1mEounWsUweMPKV2bWBZGT5Gp0liBK3tColD6erf0eMS+gFKSlhuA/t6Ybp6PR0 MnMh9co4LaVd57l0KTWRaRkUE2cKwEEkFZEDs7fBUfPp5YZK3YUjTxATML7SrvHQpxn5 IiaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=oaKrElE1AMJOvXqLWag42ZjIrLYDCFvrlaWvSZAKArw=; fh=JLcZCPavxVlmT12/G5pUlQ1nymhUvgbZqbZj8xSTNrY=; b=SMAn2RufXVX9wGb2eU//6sszg3saCSuT3TKioYmGLKdzLZqYdj9/0DvktRsxOmKkfI 3809zTcH1GlqlxSvbfv5cfatDphjXtXGMqAskwtK+kDf0PdpWCSMUjAgo2XcUnM3DhMu J4Rdie7ecsTiXqD1iPII+6gWpFBNUsG3yPNusNblqvqOrvNN7fgv2Y8duaO0H9slD9eX LT6fJyjP4ZRH9B0tpr1rzMe93ttiQcTqQUbWsq95+czzHtJQKeOW5+zQezdpsvW71PqA wQuo6FPST7xn6nvKj5rqc8pwlhRqbGsFce6KPPnOA4da5ughpInr4WnoWaR78YHN58/A TJCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r3gg9VO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i15-20020a17090acf8f00b002774c17dd73si12040918pju.11.2023.11.28.06.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:40:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r3gg9VO5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C432680B01D3; Tue, 28 Nov 2023 06:40:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345741AbjK1OkO (ORCPT + 99 others); Tue, 28 Nov 2023 09:40:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345197AbjK1OkN (ORCPT ); Tue, 28 Nov 2023 09:40:13 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F192D5B for ; Tue, 28 Nov 2023 06:40:19 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40b4c2ef5cdso6231565e9.2 for ; Tue, 28 Nov 2023 06:40:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701182418; x=1701787218; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=oaKrElE1AMJOvXqLWag42ZjIrLYDCFvrlaWvSZAKArw=; b=r3gg9VO5gCcnwDOz0pufW2ZafaiK/KADozXnqcNaxv+Agpv96S42mZj66g9d0umPKr lz5sG4rJEKW7g+9znCdibcl1tNEbBsNY/z8oaUONLWxar3OUa6OALrZL373AZXtuAH6I z6gRYIte5SJikACtGjR4dsNpRkwo7DvEY9jvxMYjN+VKRg6I8lrdujCXlArsX/OyykxZ fkRhz2338ofvFMnaLqiQLmx9EXgioLA3R3FrDBiMnvoIGYeUPIRYzJQCmUh64bqhwOYk lBt/3l31k9jlDmI7njU9gtLDaDx3VurxDLFlpy0IFakFZA9UVmmCANEfS7NsBaJp+X8A 50Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701182418; x=1701787218; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oaKrElE1AMJOvXqLWag42ZjIrLYDCFvrlaWvSZAKArw=; b=IWuJyOdCBkZl0vMYD8CUGL2t43JWtX9s5i71OJOccfKASAJtRbYD/SQUEsSYSGMM+6 usiwkW+n/c+R3Hj6Ry8GAg0APr216ZNHIspCvp/FeVs4a18TJOnue6s8fdyj9mH+jBX1 yHOO2GJpMY4cVTHiXSthiNF1j5x12P5ZJoXfL4uttQICmEGqv5MmLhibze4hBoXUqogH 11R3JWdvBEKmn99j9dCXgFj42j65v7NUASrhtNHsYrhSYNjc4zM5AKRbfkRLBXoYPxAL N9FHpqnBWvDLsfQNM34Yec1YmN5NaFXvryZ4r2w4Q1f6EvRgfFsiTHRdkO+twV0VykWy zUAQ== X-Gm-Message-State: AOJu0Yyws9rYZAoVv2YoDnPSRI4pGcmM6sFYqg+JjOgdc37gOgMWQ8Vf WThKJ2blJRibN+Mlb8929mXp7waFhYKtc1ZZSs5y1vJO X-Received: by 2002:a05:600c:4f82:b0:40b:2b42:a1c9 with SMTP id n2-20020a05600c4f8200b0040b2b42a1c9mr10704074wmq.23.1701182417945; Tue, 28 Nov 2023 06:40:17 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c450e00b0040b37f107c4sm16321352wmo.16.2023.11.28.06.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:40:17 -0800 (PST) Date: Tue, 28 Nov 2023 17:40:14 +0300 From: Dan Carpenter To: Jack Zhu Cc: Changhuang Liang , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] media: staging: starfive: camss: fix off by one in isp_enum_mbus_code() Message-ID: <7d222638-2d19-466d-8dd4-9e1ceb1d46f3@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:40:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783819063320382716 X-GMAIL-MSGID: 1783819063320382716 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,