From: Cengiz Can <cengiz@kernel.wtf>
To: "Daniel W . S . Almeida" <dwlsalmeida@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Cengiz Can <cengiz@kernel.wtf>
Subject: [PATCH] media: vidtv: fix read after free
Date: Mon, 30 Nov 2020 12:28:26 +0300 [thread overview]
Message-ID: <20201130092825.28532-1-cengiz@kernel.wtf> (raw)
`vidtv_channel_si_destroy` function has a call to
`vidtv_psi_pat_table_destroy` that frees Program Association Table.
However it is followed by a loop that iterates over the count of Program
Map Tables. This obviously accesses an invalid memory.
Eliminate this by making a copy of num_pmt before free'ing Program
Association Table and loop on it instead.
Signed-off-by: Cengiz Can <cengiz@kernel.wtf>
---
drivers/media/test-drivers/vidtv/vidtv_channel.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_channel.c b/drivers/media/test-drivers/vidtv/vidtv_channel.c
index 8ad6c0744d36..4af39a8786a7 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_channel.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_channel.c
@@ -503,10 +503,13 @@ int vidtv_channel_si_init(struct vidtv_mux *m)
void vidtv_channel_si_destroy(struct vidtv_mux *m)
{
u32 i;
+ u16 num_pmt;
+
+ num_pmt = m->si.pat->num_pmt;
vidtv_psi_pat_table_destroy(m->si.pat);
- for (i = 0; i < m->si.pat->num_pmt; ++i)
+ for (i = 0; i < num_pmt; ++i)
vidtv_psi_pmt_table_destroy(m->si.pmt_secs[i]);
kfree(m->si.pmt_secs);
--
2.29.2
next reply other threads:[~2020-11-30 9:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 9:28 Cengiz Can [this message]
2020-12-02 12:17 ` [PATCH] media: vidtv: fix read after free Mauro Carvalho Chehab
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=20201130092825.28532-1-cengiz@kernel.wtf \
--to=cengiz@kernel.wtf \
--cc=dwlsalmeida@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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