Skip to contentSkip to conversation

Fix the risk of an oops at dvb_dmx_release

PATCH In review Mauro Carvalho Chehab 3 participants 3 messages Feb 1, 2010 – Feb 5, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix the risk of an oops at dvb_dmx_release

dvb_dmx_init tries to allocate virtual memory for 2 pointers: filter and feed.

If the second vmalloc fails, filter is freed, but the pointer keeps pointing to the old place. Later, when dvb_dmx_release() is called, it will try to free an already freed memory, causing an OOPS.

---
 drivers/media/dvb/dvb-core/dvb_demux.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/media/dvb/dvb-core/dvb_demux.c +1 -0
index b78cfb7..a78408e 100644
@@ -1246,6 +1246,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
 	dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
 	if (!dvbdemux->feed) {
 		vfree(dvbdemux->filter);
+		dvbdemux->filter = NULL;
 		return -ENOMEM;
 	}
 	for (i = 0; i < dvbdemux->filternum; i++) {
Signature · 1 line
1.6.6.1
#1 lore raw

Am Montag, den 01.02.2010, 11:35 -0200 schrieb Mauro Carvalho Chehab:

Quoted 16 lines

dvb_dmx_init tries to allocate virtual memory for 2 pointers: filter and feed.

If the second vmalloc fails, filter is freed, but the pointer keeps pointing to the old place. Later, when dvb_dmx_release() is called, it will try to free an already freed memory, causing an OOPS.

---
 drivers/media/dvb/dvb-core/dvb_demux.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/media/dvb/dvb-core/dvb_demux.c +0 -0
index b78cfb7..a78408e 100644

drivers/media/dvb/dvb-core/dvb_demux.c int dvb_dmx_init(struct dvb_demux *dvbdemux) · line 1252

Quoted 7 lines
drivers/media/dvb/dvb-core/dvb_demux.c +1 -0
@@ -1246,6 +1246,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
 	dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
 	if (!dvbdemux->feed) {
 		vfree(dvbdemux->filter);
+		dvbdemux->filter = NULL;
 		return -ENOMEM;
 	}
 	for (i = 0; i < dvbdemux->filternum; i++) {

Hi Mauro,

I tested this one.
It does not help the problem with alevt-dvb described by me, but the horrible crash behaviour where nothing goes without hard reset after the second start of alevt-dvb is gone. One step - well done!

Can you explain in some words what specific problems the other patch resolves?

Thanks

CS

Reviewed-by on v1 1/1
#2 lore raw
In reply to Mauro Carvalho Chehab
Quoted 7 lines · Mauro Carvalho Chehab

dvb_dmx_init tries to allocate virtual memory for 2 pointers: filter and feed.

If the second vmalloc fails, filter is freed, but the pointer keeps pointing to the old place. Later, when dvb_dmx_release() is called, it will try to free an already freed memory, causing an OOPS.

Looks good.

Quoted 16 lines
---
 drivers/media/dvb/dvb-core/dvb_demux.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/media/dvb/dvb-core/dvb_demux.c +1 -0
index b78cfb7..a78408e 100644
@@ -1246,6 +1246,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
 	dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
 	if (!dvbdemux->feed) {
 		vfree(dvbdemux->filter);
+		dvbdemux->filter = NULL;
 		return -ENOMEM;
 	}
 	for (i = 0; i < dvbdemux->filternum; i++) {