* [PATCH 0/4] media: iris: Fix core init failure recovery and iris_open error handling
@ 2026-12-03 10:22 Gourav Kumar
2026-12-03 10:22 ` [PATCH 1/4] media: iris: Tear the core down when the firmware does not become ready Gourav Kumar
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Gourav Kumar @ 2026-12-03 10:22 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Stefan Schmidt,
Hans Verkuil, Vedang Nagar, Dmitry Baryshkov, Konrad Dybcio
Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
Gourav Kumar, stable
This series fixes a few issues in the iris driver when the core is
brought up and an instance is created in open.
1. Tear the core down when the firmware does not become ready in time,
so the next open starts from a clean state.
2. Fix a NULL dereference and memory leaks on the iris_open error
paths.
3. Return the real error when the m2m setup in iris_open fails.
4. Drop duplicate defines.
Signed-off-by: Gourav Kumar <gourav.kumar@oss.qualcomm.com>
---
Gourav Kumar (4):
media: iris: Tear the core down when the firmware does not become ready
media: iris: Fix NULL dereference and leaks in the iris_open error handling
media: iris: Return the real error when the m2m setup in iris_open fails
media: iris: Drop duplicate defines
drivers/media/platform/qcom/iris/iris_buffer.c | 3 ---
drivers/media/platform/qcom/iris/iris_core.c | 6 +++++-
drivers/media/platform/qcom/iris/iris_vdec.c | 2 ++
drivers/media/platform/qcom/iris/iris_venc.c | 5 +----
drivers/media/platform/qcom/iris/iris_vidc.c | 17 +++++++++--------
drivers/media/platform/qcom/iris/iris_vpu_buffer.h | 6 ------
6 files changed, 17 insertions(+), 22 deletions(-)
---
base-commit: 799dd936553182df5770dde7f38d94c8337df75a
change-id: 20261130-iris-core-open-error-fixes-f6c32d92aa22
Best regards,
--
Gourav Kumar <gourav.kumar@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] media: iris: Tear the core down when the firmware does not become ready
2026-12-03 10:22 [PATCH 0/4] media: iris: Fix core init failure recovery and iris_open error handling Gourav Kumar
@ 2026-12-03 10:22 ` Gourav Kumar
2026-12-03 10:22 ` [PATCH 2/4] media: iris: Fix NULL dereference and leaks in the iris_open error handling Gourav Kumar
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Gourav Kumar @ 2026-12-03 10:22 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Stefan Schmidt,
Hans Verkuil, Vedang Nagar, Dmitry Baryshkov, Konrad Dybcio
Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
Gourav Kumar, stable
If the firmware does not report ready in time, core init returns an
error but leaves the core powered, with the firmware loaded and the
queues allocated, and the state set to error. The next open only resets
the state, and the one after that repeats the whole initialisation on
top of the old one. The queue DMA buffers are leaked, clocks and power
domains are enabled twice, and the firmware is loaded again while it is
still running.
Deinitialise the core when the wait fails, so that the next open starts
from a clean state.
Cc: stable@vger.kernel.org
Fixes: fb583a214337 ("media: iris: introduce host firmware interface with necessary hooks")
Signed-off-by: Gourav Kumar <gourav.kumar@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/iris/iris_core.c b/drivers/media/platform/qcom/iris/iris_core.c
index d558475986ff0..e9b2c11f255ff 100644
--- a/drivers/media/platform/qcom/iris/iris_core.c
+++ b/drivers/media/platform/qcom/iris/iris_core.c
@@ -98,7 +98,11 @@ int iris_core_init(struct iris_core *core)
mutex_unlock(&core->lock);
- return iris_wait_for_system_response(core);
+ ret = iris_wait_for_system_response(core);
+ if (ret)
+ iris_core_deinit(core);
+
+ return ret;
error_unload_fw:
iris_fw_unload(core);
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] media: iris: Fix NULL dereference and leaks in the iris_open error handling
2026-12-03 10:22 [PATCH 0/4] media: iris: Fix core init failure recovery and iris_open error handling Gourav Kumar
2026-12-03 10:22 ` [PATCH 1/4] media: iris: Tear the core down when the firmware does not become ready Gourav Kumar
@ 2026-12-03 10:22 ` Gourav Kumar
2026-12-03 10:22 ` [PATCH 3/4] media: iris: Return the real error when the m2m setup in iris_open fails Gourav Kumar
2026-12-03 10:22 ` [PATCH 4/4] media: iris: Drop duplicate defines Gourav Kumar
3 siblings, 0 replies; 5+ messages in thread
From: Gourav Kumar @ 2026-12-03 10:22 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Stefan Schmidt,
Hans Verkuil, Vedang Nagar, Dmitry Baryshkov, Konrad Dybcio
Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
Gourav Kumar, stable
The decoder instance init uses the format structures right after
allocating them, without checking for NULL, so a failed allocation
crashes when a decoder node is opened. The open error paths also leak
memory. If the instance init fails after the formats were allocated,
they are not freed. If adding the session fails, the control handler is
not freed.
Return -ENOMEM when an allocation fails and free the control handler
and the formats on the error paths, in reverse order of setup. As open
now frees the formats, drop the free from the encoder instance init so
they are freed only once.
Cc: stable@vger.kernel.org
Fixes: 38fc8beaba55 ("media: iris: implement reqbuf ioctl with vb2_queue_setup")
Fixes: 33be1dde17e3 ("media: iris: implement iris v4l2_ctrl_ops")
Fixes: 397ebadcbc21 ("media: iris: reject open() when the session limit is reached")
Signed-off-by: Gourav Kumar <gourav.kumar@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_vdec.c | 2 ++
drivers/media/platform/qcom/iris/iris_venc.c | 5 +----
drivers/media/platform/qcom/iris/iris_vidc.c | 9 +++++----
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c
index 0dd33ff447bb0..2c7d173ebd0b8 100644
--- a/drivers/media/platform/qcom/iris/iris_vdec.c
+++ b/drivers/media/platform/qcom/iris/iris_vdec.c
@@ -24,6 +24,8 @@ int iris_vdec_inst_init(struct iris_inst *inst)
inst->fmt_src = kzalloc_obj(*inst->fmt_src);
inst->fmt_dst = kzalloc_obj(*inst->fmt_dst);
+ if (!inst->fmt_src || !inst->fmt_dst)
+ return -ENOMEM;
inst->fw_min_count = 0;
diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/platform/qcom/iris/iris_venc.c
index 2f2c56bf9122c..0be34d63ea022 100644
--- a/drivers/media/platform/qcom/iris/iris_venc.c
+++ b/drivers/media/platform/qcom/iris/iris_venc.c
@@ -22,11 +22,8 @@ int iris_venc_inst_init(struct iris_inst *inst)
inst->fmt_src = kzalloc_obj(*inst->fmt_src);
inst->fmt_dst = kzalloc_obj(*inst->fmt_dst);
- if (!inst->fmt_src || !inst->fmt_dst) {
- kfree(inst->fmt_src);
- kfree(inst->fmt_dst);
+ if (!inst->fmt_src || !inst->fmt_dst)
return -ENOMEM;
- }
f = inst->fmt_dst;
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index 05aab6e3005d5..b99375d7138cf 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -221,20 +221,21 @@ int iris_open(struct file *filp)
else if (inst->domain == ENCODER)
ret = iris_venc_inst_init(inst);
if (ret)
- goto fail_m2m_ctx_release;
+ goto fail_free_fmt;
ret = iris_add_session(inst);
if (ret)
- goto fail_inst_deinit;
+ goto fail_free_ctrls;
inst->fh.m2m_ctx = inst->m2m_ctx;
return 0;
-fail_inst_deinit:
+fail_free_ctrls:
+ v4l2_ctrl_handler_free(&inst->ctrl_handler);
+fail_free_fmt:
kfree(inst->fmt_src);
kfree(inst->fmt_dst);
-fail_m2m_ctx_release:
v4l2_m2m_ctx_release(inst->m2m_ctx);
fail_m2m_release:
v4l2_m2m_release(inst->m2m_dev);
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] media: iris: Return the real error when the m2m setup in iris_open fails
2026-12-03 10:22 [PATCH 0/4] media: iris: Fix core init failure recovery and iris_open error handling Gourav Kumar
2026-12-03 10:22 ` [PATCH 1/4] media: iris: Tear the core down when the firmware does not become ready Gourav Kumar
2026-12-03 10:22 ` [PATCH 2/4] media: iris: Fix NULL dereference and leaks in the iris_open error handling Gourav Kumar
@ 2026-12-03 10:22 ` Gourav Kumar
2026-12-03 10:22 ` [PATCH 4/4] media: iris: Drop duplicate defines Gourav Kumar
3 siblings, 0 replies; 5+ messages in thread
From: Gourav Kumar @ 2026-12-03 10:22 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Stefan Schmidt,
Hans Verkuil, Vedang Nagar, Dmitry Baryshkov, Konrad Dybcio
Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
Gourav Kumar, stable
Creating the m2m device and context returns an ERR_PTR() carrying the
reason for the failure, but open replaces it with -EINVAL. User space
therefore cannot tell an out-of-memory condition from an invalid
request, and may treat a transient failure as a programming error.
Neither function returns NULL, so use IS_ERR() instead of
IS_ERR_OR_NULL() and return the error from the pointer.
Cc: stable@vger.kernel.org
Fixes: fa186c97e3d2 ("media: iris: implement iris v4l2 file ops")
Signed-off-by: Gourav Kumar <gourav.kumar@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_vidc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index b99375d7138cf..e7e58790375f8 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -205,14 +205,14 @@ int iris_open(struct file *filp)
iris_v4l2_fh_init(inst, filp);
inst->m2m_dev = v4l2_m2m_init(&iris_m2m_ops);
- if (IS_ERR_OR_NULL(inst->m2m_dev)) {
- ret = -EINVAL;
+ if (IS_ERR(inst->m2m_dev)) {
+ ret = PTR_ERR(inst->m2m_dev);
goto fail_v4l2_fh_deinit;
}
inst->m2m_ctx = v4l2_m2m_ctx_init(inst->m2m_dev, inst, iris_m2m_queue_init);
- if (IS_ERR_OR_NULL(inst->m2m_ctx)) {
- ret = -EINVAL;
+ if (IS_ERR(inst->m2m_ctx)) {
+ ret = PTR_ERR(inst->m2m_ctx);
goto fail_m2m_release;
}
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] media: iris: Drop duplicate defines
2026-12-03 10:22 [PATCH 0/4] media: iris: Fix core init failure recovery and iris_open error handling Gourav Kumar
` (2 preceding siblings ...)
2026-12-03 10:22 ` [PATCH 3/4] media: iris: Return the real error when the m2m setup in iris_open fails Gourav Kumar
@ 2026-12-03 10:22 ` Gourav Kumar
3 siblings, 0 replies; 5+ messages in thread
From: Gourav Kumar @ 2026-12-03 10:22 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Stefan Schmidt,
Hans Verkuil, Vedang Nagar, Dmitry Baryshkov, Konrad Dybcio
Cc: linux-media, linux-arm-msm, linux-kernel, Bryan O'Donoghue,
Gourav Kumar
Several defines are defined twice with the same value, either within
iris_vpu_buffer.h or again in iris_buffer.c, which already includes that
header.
Remove the second definitions. No functional change.
Signed-off-by: Gourav Kumar <gourav.kumar@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_buffer.c | 3 ---
drivers/media/platform/qcom/iris/iris_vpu_buffer.h | 6 ------
2 files changed, 9 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
index eb8de60c1177f..5801679bb07eb 100644
--- a/drivers/media/platform/qcom/iris/iris_buffer.c
+++ b/drivers/media/platform/qcom/iris/iris_buffer.c
@@ -12,8 +12,6 @@
#include "iris_vpu_buffer.h"
#define PIXELS_4K 4096
-#define MAX_WIDTH 4096
-#define MAX_HEIGHT 2304
#define Y_STRIDE_ALIGN 128
#define Y_STRIDE_ALIGN_P010 256
#define UV_STRIDE_ALIGN 128
@@ -24,7 +22,6 @@
#define UV_SCANLINE_ALIGN_QC08C 32
#define META_STRIDE_ALIGNED 64
#define META_SCANLINE_ALIGNED 16
-#define NUM_MBS_4K (DIV_ROUND_UP(MAX_WIDTH, 16) * DIV_ROUND_UP(MAX_HEIGHT, 16))
/*
* NV12:
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
index 2085e316a6bd8..404e1b1c89263 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
+++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
@@ -106,7 +106,6 @@ struct iris_inst;
#define MAX_PE_NBR_DATA_LCU16_LINE_BUFFER_SIZE 96
#define MAX_PE_NBR_DATA_LCU32_LINE_BUFFER_SIZE 192
-#define MAX_FE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE 64
#define MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE 16
#define MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE 384
#define MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE_AR50LT 176
@@ -117,8 +116,6 @@ struct iris_inst;
#define AV1D_LCU_MAX_SIZE_PELS 128
#define AV1D_LCU_MIN_SIZE_PELS 64
#define AV1D_MAX_TILE_COLS 64
-#define MAX_PE_NBR_DATA_LCU32_LINE_BUFFER_SIZE 192
-#define MAX_PE_NBR_DATA_LCU16_LINE_BUFFER_SIZE 96
#define AV1D_NUM_HW_PIC_BUF 16
#define AV1D_NUM_FRAME_HEADERS 16
#define SIZE_AV1D_SEQUENCE_HEADER 768
@@ -155,9 +152,6 @@ struct iris_inst;
#define BITS_PER_PIX 16
#define NUM_LINES_LUMA 10
#define NUM_LINES_CHROMA 6
-#define AV1D_LCU_MAX_SIZE_PELS 128
-#define AV1D_LCU_MIN_SIZE_PELS 64
-#define AV1D_MAX_TILE_COLS 64
#define BITS_PER_CTRL_PACK 128
#define NUM_CTRL_PACK_LCU 10
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-03 10:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 10:22 [PATCH 0/4] media: iris: Fix core init failure recovery and iris_open error handling Gourav Kumar
2026-12-03 10:22 ` [PATCH 1/4] media: iris: Tear the core down when the firmware does not become ready Gourav Kumar
2026-12-03 10:22 ` [PATCH 2/4] media: iris: Fix NULL dereference and leaks in the iris_open error handling Gourav Kumar
2026-12-03 10:22 ` [PATCH 3/4] media: iris: Return the real error when the m2m setup in iris_open fails Gourav Kumar
2026-12-03 10:22 ` [PATCH 4/4] media: iris: Drop duplicate defines Gourav Kumar
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®