From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Lin Huiyi <xinghui79@qq.com>, s.nawrocki@samsung.com
Cc: mchehab@kernel.org, krzk@kernel.org, peter.griffin@linaro.org,
alim.akhtar@samsung.com, linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH] media: exynos4-is: fimc: Fix reading uninitialized plane sizes
Date: Tue, 1 Dec 2026 13:37:32 +0100 [thread overview]
Message-ID: <22c24d86-6909-432d-af8c-8fe7a5c10b60@kernel.org> (raw)
In-Reply-To: <tencent_3AEB0A8D1E5C4AA6AE465EFAB4B504E4D606@qq.com>
On 29/11/2026 17:54, Lin Huiyi wrote:
> fimc_get_sensor_frame_desc() pre-fills the media bus frame descriptor
> entries from plane_fmt[].sizeimage before invoking the sensor subdev
> operation. The only call site that sets the frame description
> (__video_try_or_set_format(), try=true) passes a properly initialized
> array, but fimc_pipeline_validate() passes a plain uninitialized stack
> array and only wants to query the sensor with get_frame_desc(). The
> pre-fill thus reads uninitialized stack memory and passes it to the
> sensor driver.
>
> Only fill the descriptor entries when the caller is going to set the
> frame description.
>
> Signed-off-by: Lin Huiyi <xinghui79@qq.com>
> ---
> .../media/platform/samsung/exynos4-is/fimc-capture.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-capture.c b/drivers/media/platform/samsung/exynos4-is/fimc-capture.c
> index 8d7e7b1905..ecfff86f9c 100644
> --- a/drivers/media/platform/samsung/exynos4-is/fimc-capture.c
> +++ b/drivers/media/platform/samsung/exynos4-is/fimc-capture.c
> @@ -858,8 +858,14 @@ static int fimc_get_sensor_frame_desc(struct v4l2_subdev *sensor,
> int i, ret;
> int pad;
>
> - for (i = 0; i < num_planes; i++)
> - fd.entry[i].length = plane_fmt[i].sizeimage;
> + /*
> + * Pre-fill the frame descriptor with the caller provided plane
> + * sizes. Callers which only query the sensor pass an uninitialized
> + * array here, so only do this when setting the frame description.
> + */
> + if (try)
> + for (i = 0; i < num_planes; i++)
> + fd.entry[i].length = plane_fmt[i].sizeimage;
>
> pad = sensor->entity.num_pads - 1;
> if (try)
I'm not sure this code is right, and it may have been wrong in the first place.
It calls set_frame_desc if try == true, but when called from fimc_cap_s_fmt_mplane()
the 'try' argument is false, and in that case fimc_get_sensor_frame_desc actually
calls get_frame_desc. That doesn't feel right.
I wonder if anyone from Samsung has a board to test with, since I think the current
code is just wrong. Not helped by poor naming.
I think that:
1) Make a fimc_set_sensor_frame_desc function that calls set_frame_desc, and the
existing fimc_get_sensor_frame_desc just calls get_frame_desc. Both functions
can drop the 'bool try'. For the 'set' variant initialize fd.entry[i].length
as per your current patch.
2) Call the correct function elsewhere in the code.
Regards,
Hans
prev parent reply other threads:[~2026-12-01 12:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 16:54 [PATCH] media: exynos4-is: fimc: Fix reading uninitialized plane sizes Lin Huiyi
2026-12-01 12:37 ` Hans Verkuil [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22c24d86-6909-432d-af8c-8fe7a5c10b60@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=peter.griffin@linaro.org \
--cc=s.nawrocki@samsung.com \
--cc=xinghui79@qq.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox