[PATCH] media: exynos4-is: fimc: Fix reading uninitialized plane sizes
Lin Huiyi
xinghui79 at qq.com
Sun Nov 29 08:54:08 PST 2026
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 at 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
More information about the linux-arm-kernel
mailing list