From 7b1dde03314912cfa9a5fa34ea9423df0db13860 Mon Sep 17 00:00:00 2001 From: Andy Walls Date: Thu, 31 Dec 2009 01:35:08 -0300 Subject: V4L/DVB (13904): cx18: Fix TS and IDX stream buffer memory leak on module unload Fix a long standing memory leak of stream buffers for streams that did not have a struct video_device allocated: namely the TS and IDX streams. Signed-off-by: Andy Walls Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/cx18/cx18-streams.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'drivers/media/video/cx18/cx18-streams.c') diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 9be603c00fb4..1764971f3dac 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c @@ -319,11 +319,27 @@ void cx18_streams_cleanup(struct cx18 *cx, int unregister) /* Teardown all streams */ for (type = 0; type < CX18_MAX_STREAMS; type++) { - if (cx->streams[type].dvb.enabled) { - cx18_dvb_unregister(&cx->streams[type]); - cx->streams[type].dvb.enabled = false; + + /* No struct video_device, but can have buffers allocated */ + if (type == CX18_ENC_STREAM_TYPE_TS) { + if (cx->streams[type].dvb.enabled) { + cx18_dvb_unregister(&cx->streams[type]); + cx->streams[type].dvb.enabled = false; + cx18_stream_free(&cx->streams[type]); + } + continue; + } + + /* No struct video_device, but can have buffers allocated */ + if (type == CX18_ENC_STREAM_TYPE_IDX) { + if (cx->stream_buffers[type] != 0) { + cx->stream_buffers[type] = 0; + cx18_stream_free(&cx->streams[type]); + } + continue; } + /* If struct video_device exists, can have buffers allocated */ vdev = cx->streams[type].video_dev; cx->streams[type].video_dev = NULL; -- cgit v1.2.3