Skip to content

Commit 130474b

Browse files
hverkuilgregkh
authored andcommitted
media: vivid: fix wrong pixel_array control size
commit 3e43442 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: 6bc7643 ("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>
1 parent 6b07fdb commit 130474b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

drivers/media/test-drivers/vivid/vivid-ctrls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ static const struct v4l2_ctrl_config vivid_ctrl_u8_pixel_array = {
244244
.min = 0x00,
245245
.max = 0xff,
246246
.step = 1,
247-
.dims = { 640 / PIXEL_ARRAY_DIV, 360 / PIXEL_ARRAY_DIV },
247+
.dims = { DIV_ROUND_UP(360, PIXEL_ARRAY_DIV),
248+
DIV_ROUND_UP(640, PIXEL_ARRAY_DIV) },
248249
};
249250

250251
static const struct v4l2_ctrl_config vivid_ctrl_s32_array = {

drivers/media/test-drivers/vivid/vivid-vid-cap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
454454
if (keep_controls)
455455
return;
456456

457-
dims[0] = roundup(dev->src_rect.width, PIXEL_ARRAY_DIV);
458-
dims[1] = roundup(dev->src_rect.height, PIXEL_ARRAY_DIV);
457+
dims[0] = DIV_ROUND_UP(dev->src_rect.height, PIXEL_ARRAY_DIV);
458+
dims[1] = DIV_ROUND_UP(dev->src_rect.width, PIXEL_ARRAY_DIV);
459459
v4l2_ctrl_modify_dimensions(dev->pixel_array, dims);
460460
}
461461

0 commit comments

Comments
 (0)