Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: exynos4-is: fimc: Fix reading uninitialized plane sizes
@ 2026-11-29 16:54 Lin Huiyi
  2026-12-01 12:37 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Huiyi @ 2026-11-29 16:54 UTC (permalink / raw)
  To: s.nawrocki
  Cc: mchehab, krzk, peter.griffin, alim.akhtar, linux-media,
	linux-arm-kernel, linux-samsung-soc, Lin Huiyi

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)
-- 
2.56.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox