From d06ea829015ef802ba0a0ddd4e53fd519def9154 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Thu, 24 Jul 2025 16:01:15 +0100 Subject: [PATCH] util: pattern: Fix chroma offset for insert_value_yuv_planar The chroma offset calculation resulted in the running beyond the end of the buffer. eg For ysub=2, y=0 and y=1 should result in writing the same U & V line, but chroma_offset = (y + 1) / ysub; resulted in them going to different lines, potentially running off the end of the buffer and causing a seg fault. Update the calculation so lines 0 to (ysub-1) all write the same output line. Fixes: 40aeab6fd5b8 ("modetest: util: pattern: add new patterns") Signed-off-by: Dave Stevenson --- tests/util/pattern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index f3af76f2..49808033 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -1951,7 +1951,7 @@ static void insert_value_yuv_planar(const struct util_format_info *info, unsigned int cs = yuv->chroma_stride; unsigned int xsub = yuv->xsub; unsigned int ysub = yuv->ysub; - unsigned int chroma_offset = (y + 1) / ysub; + unsigned int chroma_offset = y / ysub; unsigned char *y_mem = planes[0] + (y * stride); unsigned char *u_mem = planes[1]; unsigned char *v_mem = planes[2];