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: 13471270 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="r3gg9VO5" Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ED97D53 for ; Tue, 28 Nov 2023 06:40:19 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40b4c2ef5cdso6231555e9.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=r0bMAOFqkgWSpMXYQqDjBrwIZs/3kOisgsZGF5UMNkKpDZalVE62Cy/cqzh0FvCYy5 y3T7d0HOX1MOjWo0NitwyS1EoreKyEQu5TyQcXsnhIGBM8Gtv2aYTNDRxgifCAtK5uoG AX/FNaB0ASF8SaC5e3XHBUG82BkdqTvdTfwdzCSMnSuEqqzO5aZtJ8xIPT7GEat+5/mD p8UyPRZubPe3M54GSQyc7imZhlLQJv1Kp2CzrzMrP3hP9mJftrlg93rZ++T9gimRdLoS 8IJGNUDVUYVaSkhRou3iJinQW9k3ApH5DTAFPjM4UP4bOlkpzrolodb5+6vIJoVtYLdC uteQ== X-Gm-Message-State: AOJu0YxDWzvBe51ipgS3fuWNPyRzr7NVsNbA6yeaRhr0+Hlv3jEyYjZT TBd+rAWFN3HPtVVRniGKtLmXMQ== X-Google-Smtp-Source: AGHT+IEUXsu35JfaoTse6WpNi0aat3trZZEVzz9HHjmeo+pJm7QYeZQ28Vz4IccP7yCA63IgMU75YA== 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding 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,