Re: [PATCH v2 3/3] media: qcom: iris: venc: reject encoder crop rectangles larger than the source

From: bod

Date: Mon Nov 30 2026 - 07:30:22 EST


On 2026-11-17 11:46 +0100, Loic Poulain wrote:
> iris_venc_s_selection() bounded the V4L2_SEL_TGT_CROP rectangle by
> inst->fmt_src, the padded buffer geometry, instead of the visible
> resolution in enc_raw_width and enc_raw_height. fmt_src is rounded up, so
> userspace could set a crop larger than the frame it submits.
>
> iris_hfi_gen2_set_crop_offsets() then underflows
>
> bottom_offset = inst->enc_raw_height - inst->crop.height;
>
> and the encode fails silently. All ioctls succeed and the EOS event is
> delivered, but the encoder produces no data and nothing is logged.
>
> Bound the rectangle by enc_raw_* instead.
>
> v4l2-ctl -d /dev/video1 \
> --set-fmt-video-out=width=1280,height=720,pixelformat=NV12 \
> --set-selection-output=target=crop,width=1280,height=730 \
> --stream-mmap --stream-out-mmap --stream-count=30 \
> --stream-to=out.h264
>
> Before, 1280x730 is accepted because fmt_src is 1280x736, and out.h264 is
> 0 bytes. After:
>
> VIDIOC_S_SELECTION: failed: Invalid argument
>
> Rectangles within the source, like 1280x704 and 640x360, are still
> accepted.
>
> Fixes: d9967fa37ca9 ("media: qcom: iris: Improve format alignment for encoder")
> Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
---
bod