From: Alfie Varghese <alfievarghese22@gmail.com>
To: neil.armstrong@linaro.org, gregkh@linuxfoundation.org
Cc: linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Alfie Varghese <alfievarghese22@gmail.com>
Subject: [PATCH] staging: media: meson: vdec: fix UAF, memory leak and NULL derefs
Date: Mon, 13 Jul 2026 23:08:59 +0530 [thread overview]
Message-ID: <20260713173859.643-1-alfievarghese22@gmail.com> (raw)
This combined commit fixes several pre-existing issues identified in the
Amlogic video decoder driver:
1. Fix a critical Use-After-Free in vdec_close() by synchronously
canceling the sess->esparser_queue_work before freeing the session.
2. Fix a memory leak in vdec_close() by freeing the session control
handler via v4l2_ctrl_handler_free().
3. Prevent a potential NULL pointer dereference in vdec_probe() by adding
a NULL check for of_match_node()'s return value.
4. Prevent a potential NULL pointer dereference in vdec_isr() and
vdec_threaded_isr() by adding NULL checks for core->cur_sess.
Signed-off-by: Alfie Varghese <alfievarghese22@gmail.com>
---
drivers/staging/media/meson/vdec/vdec.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
index a039d925c0fe..b794ad53711c 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -926,11 +926,15 @@ static int vdec_close(struct file *file)
{
struct amvdec_session *sess = file_to_amvdec_session(file);
+ cancel_work_sync(&sess->esparser_queue_work);
+
v4l2_m2m_ctx_release(sess->m2m_ctx);
v4l2_m2m_release(sess->m2m_dev);
v4l2_fh_del(&sess->fh, file);
v4l2_fh_exit(&sess->fh);
+ v4l2_ctrl_handler_free(&sess->ctrl_handler);
+
mutex_destroy(&sess->lock);
mutex_destroy(&sess->bufs_recycle_lock);
@@ -953,6 +957,9 @@ static irqreturn_t vdec_isr(int irq, void *data)
struct amvdec_core *core = data;
struct amvdec_session *sess = core->cur_sess;
+ if (!sess)
+ return IRQ_NONE;
+
sess->last_irq_jiffies = get_jiffies_64();
return sess->fmt_out->codec_ops->isr(sess);
@@ -963,6 +970,9 @@ static irqreturn_t vdec_threaded_isr(int irq, void *data)
struct amvdec_core *core = data;
struct amvdec_session *sess = core->cur_sess;
+ if (!sess)
+ return IRQ_NONE;
+
return sess->fmt_out->codec_ops->threaded_isr(sess);
}
@@ -1020,6 +1030,8 @@ static int vdec_probe(struct platform_device *pdev)
return PTR_ERR(core->canvas);
of_id = of_match_node(vdec_dt_match, dev->of_node);
+ if (!of_id)
+ return -ENODEV;
core->platform = of_id->data;
if (core->platform->revision == VDEC_REVISION_G12A ||
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next reply other threads:[~2026-07-13 17:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 17:38 Alfie Varghese [this message]
2026-07-13 18:01 ` sashiko-bot
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=20260713173859.643-1-alfievarghese22@gmail.com \
--to=alfievarghese22@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=neil.armstrong@linaro.org \
/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