]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: vivid: fix wrong pixel_array control size
authorHans Verkuil <hverkuil@xs4all.nl>
Sun, 6 Jul 2025 10:55:40 +0000 (12:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:26:08 +0000 (16:26 +0200)
commit 3e43442d4994c9e1e202c98129a87e330f7faaed upstream.

The pixel_array control size was calculated incorrectly:
the dimensions were swapped (dims[0] should be the height), and the
values should be the width or height divided by PIXEL_ARRAY_DIV
and rounded up. So don't use roundup, but use DIV_ROUND_UP instead.

This bug is harmless in the sense that nothing will break, except that
it consumes way too much memory for this control.

Fixes: 6bc7643d1b9c ("media: vivid: add pixel_array test control")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/test-drivers/vivid/vivid-ctrls.c
drivers/media/test-drivers/vivid/vivid-vid-cap.c

index 92b1a75984706669b2d084855403d199db2b27b9..0e549777860fb7074276e08bfa290cbdf86301ef 100644 (file)
@@ -238,7 +238,8 @@ static const struct v4l2_ctrl_config vivid_ctrl_u8_pixel_array = {
        .min = 0x00,
        .max = 0xff,
        .step = 1,
-       .dims = { 640 / PIXEL_ARRAY_DIV, 360 / PIXEL_ARRAY_DIV },
+       .dims = { DIV_ROUND_UP(360, PIXEL_ARRAY_DIV),
+                 DIV_ROUND_UP(640, PIXEL_ARRAY_DIV) },
 };
 
 static const char * const vivid_ctrl_menu_strings[] = {
index a9e0dd32d04b0c9c80092228465c20632dc24a9f..e3e3237206ab2603cc61008b5f85074b0738c80e 100644 (file)
@@ -475,8 +475,8 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
        if (keep_controls)
                return;
 
-       dims[0] = roundup(dev->src_rect.width, PIXEL_ARRAY_DIV);
-       dims[1] = roundup(dev->src_rect.height, PIXEL_ARRAY_DIV);
+       dims[0] = DIV_ROUND_UP(dev->src_rect.height, PIXEL_ARRAY_DIV);
+       dims[1] = DIV_ROUND_UP(dev->src_rect.width, PIXEL_ARRAY_DIV);
        v4l2_ctrl_modify_dimensions(dev->pixel_array, dims);
 }