diff options
author | Andy Walls <awalls@radix.net> | 2010-01-30 13:50:51 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:50 -0500 |
commit | 831f476cee704c37e7f96510135a90dfec6d00e9 (patch) | |
tree | 701bbdec5d39da9729ce51d5d90cc517d7fc2ec5 | |
parent | b4729dcbba5431bf636d3d6615709383ad5e0d34 (diff) |
V4L/DVB: cx18: Fix memory leak in cx18-alsa starting of PCM captures
The cx18_open_id is normally dynamically allocated and stored in the
filp->private_data for v4l2 file operations. The cx18-alsa routines should
not dynamically allocate a cx18_open_id because they never store it anywhere
and never free it. This change fixes that and plugs a memory leak.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/cx18/cx18-alsa-pcm.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/media/video/cx18/cx18-alsa-pcm.c b/drivers/media/video/cx18/cx18-alsa-pcm.c index 06862a69c7b0..cfa512112ca0 100644 --- a/drivers/media/video/cx18/cx18-alsa-pcm.c +++ b/drivers/media/video/cx18/cx18-alsa-pcm.c | |||
@@ -152,28 +152,20 @@ static int snd_cx18_pcm_capture_open(struct snd_pcm_substream *substream) | |||
152 | struct v4l2_device *v4l2_dev = cxsc->v4l2_dev; | 152 | struct v4l2_device *v4l2_dev = cxsc->v4l2_dev; |
153 | struct cx18 *cx = to_cx18(v4l2_dev); | 153 | struct cx18 *cx = to_cx18(v4l2_dev); |
154 | struct cx18_stream *s; | 154 | struct cx18_stream *s; |
155 | struct cx18_open_id *item; | 155 | struct cx18_open_id item; |
156 | int ret; | 156 | int ret; |
157 | 157 | ||
158 | /* Instruct the cx18 to start sending packets */ | 158 | /* Instruct the cx18 to start sending packets */ |
159 | snd_cx18_lock(cxsc); | 159 | snd_cx18_lock(cxsc); |
160 | s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM]; | 160 | s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM]; |
161 | 161 | ||
162 | /* Allocate memory */ | 162 | item.cx = cx; |
163 | item = kmalloc(sizeof(struct cx18_open_id), GFP_KERNEL); | 163 | item.type = s->type; |
164 | if (NULL == item) { | 164 | item.open_id = cx->open_id++; |
165 | snd_cx18_unlock(cxsc); | ||
166 | return -ENOMEM; | ||
167 | } | ||
168 | |||
169 | item->cx = cx; | ||
170 | item->type = s->type; | ||
171 | item->open_id = cx->open_id++; | ||
172 | 165 | ||
173 | /* See if the stream is available */ | 166 | /* See if the stream is available */ |
174 | if (cx18_claim_stream(item, item->type)) { | 167 | if (cx18_claim_stream(&item, item.type)) { |
175 | /* No, it's already in use */ | 168 | /* No, it's already in use */ |
176 | kfree(item); | ||
177 | snd_cx18_unlock(cxsc); | 169 | snd_cx18_unlock(cxsc); |
178 | return -EBUSY; | 170 | return -EBUSY; |
179 | } | 171 | } |