[PATCH] media: vidtv: fix read after free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`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@xxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux