Skip to contentSkip to conversation

media: vidtv: fix use after free in vidtv_channel_si_destroy()

PATCH In review Dan Carpenter 2 participants 2 messages Dec 3, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: vidtv: fix use after free in vidtv_channel_si_destroy()

This code frees "m->si.pat" and then dereferences it on the next line.

Fixes 039b7caed173 ("media: vidtv: add a PID entry for the NIT table")
---
 drivers/media/test-drivers/vidtv/vidtv_channel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/test-drivers/vidtv/vidtv_channel.c +2 -2
index 8ad6c0744d36..7838e6272712 100644
@@ -504,11 +504,11 @@ void vidtv_channel_si_destroy(struct vidtv_mux *m)
 {
 	u32 i;
 
-	vidtv_psi_pat_table_destroy(m->si.pat);
-
 	for (i = 0; i < m->si.pat->num_pmt; ++i)
 		vidtv_psi_pmt_table_destroy(m->si.pmt_secs[i]);
 
+	vidtv_psi_pat_table_destroy(m->si.pat);
+
 	kfree(m->si.pmt_secs);
 	vidtv_psi_sdt_table_destroy(m->si.sdt);
 	vidtv_psi_nit_table_destroy(m->si.nit);
Signature · 1 line
2.29.2
#1 lore raw

Hi Dan,

Quoted 7 lines

This code frees "m->si.pat" and then dereferences it on the next line.

Fixes 039b7caed173 ("media: vidtv: add a PID entry for the NIT table")

---
drivers/media/test-drivers/vidtv/vidtv_channel.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)

IIRC there has been a similar patch [1] that has already been accepted by Mauro..

[1]: https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

-- thanks
-- Daniel