s5p_jpeg_s_selection() passes the userspace-supplied V4L2_SEL_TGT_COMPOSE rectangle straight to exynos3250_jpeg_try_downscale(), which immediately does w_ratio = ctx->out_q.w / r->width; h_ratio = ctx->out_q.h / r->height; A VIDIOC_S_SELECTION with a zero width or height therefore divides by zero in the kernel. Nothing validates the rectangle before the divide. Reject a zero-sized rectangle up front. Fixes: 3246fdaa0ac2 ("[media] s5p-jpeg: Add support for Exynos3250 SoC") Signed-off-by: Shirong Zhao --- drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c index 7670cc7..2e8e13a 100644 --- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c @@ -1703,6 +1703,9 @@ static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx, { int w_ratio, h_ratio, scale_factor, cur_ratio, i; + if (!r->width || !r->height) + return -EINVAL; + w_ratio = ctx->out_q.w / r->width; h_ratio = ctx->out_q.h / r->height; -- 2.53.0