From: Loic Poulain <loic.poulain@oss.qualcomm.com>
To: Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Wangao Wang <wangao.wang@oss.qualcomm.com>,
Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Loic Poulain <loic.poulain@oss.qualcomm.com>
Subject: [PATCH 2/2] media: qcom: iris: venc: reject encoder crop rectangles larger than the source
Date: Thu, 12 Nov 2026 17:15:29 +0100 [thread overview]
Message-ID: <20261112-iris-fixes-v1-2-22b759c3c285@oss.qualcomm.com> (raw)
In-Reply-To: <20261112-iris-fixes-v1-0-22b759c3c285@oss.qualcomm.com>
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@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_venc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/platform/qcom/iris/iris_venc.c
index b367367ac2ccf874a00606b8b1352fed37b37a57..1af692d10bcf77060fa95c6c3906e9067d167d84 100644
--- a/drivers/media/platform/qcom/iris/iris_venc.c
+++ b/drivers/media/platform/qcom/iris/iris_venc.c
@@ -380,8 +380,8 @@ int iris_venc_s_selection(struct iris_inst *inst, struct v4l2_selection *s)
s->r.left = 0;
s->r.top = 0;
- if (s->r.width > inst->fmt_src->fmt.pix_mp.width ||
- s->r.height > inst->fmt_src->fmt.pix_mp.height)
+ if (s->r.width > inst->enc_raw_width ||
+ s->r.height > inst->enc_raw_height)
return -EINVAL;
inst->crop.left = s->r.left;
--
2.34.1
prev parent reply other threads:[~2026-11-12 16:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 16:15 [PATCH 0/2] media: qcom: iris: venc: fix encoder crop handling Loic Poulain
2026-11-12 16:15 ` [PATCH 1/2] media: qcom: iris: venc: keep the crop rectangle in visible resolution space Loic Poulain
2026-11-12 16:15 ` Loic Poulain [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261112-iris-fixes-v1-2-22b759c3c285@oss.qualcomm.com \
--to=loic.poulain@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=vikash.garodia@oss.qualcomm.com \
--cc=wangao.wang@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®