mirror of
https://github.com/torvalds/linux.git
synced 2024-12-02 09:01:34 +00:00
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>
This commit is contained in:
parent
b4729dcbba
commit
831f476cee
@ -152,28 +152,20 @@ static int snd_cx18_pcm_capture_open(struct snd_pcm_substream *substream)
|
|||||||
struct v4l2_device *v4l2_dev = cxsc->v4l2_dev;
|
struct v4l2_device *v4l2_dev = cxsc->v4l2_dev;
|
||||||
struct cx18 *cx = to_cx18(v4l2_dev);
|
struct cx18 *cx = to_cx18(v4l2_dev);
|
||||||
struct cx18_stream *s;
|
struct cx18_stream *s;
|
||||||
struct cx18_open_id *item;
|
struct cx18_open_id item;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Instruct the cx18 to start sending packets */
|
/* Instruct the cx18 to start sending packets */
|
||||||
snd_cx18_lock(cxsc);
|
snd_cx18_lock(cxsc);
|
||||||
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
|
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
|
||||||
|
|
||||||
/* Allocate memory */
|
item.cx = cx;
|
||||||
item = kmalloc(sizeof(struct cx18_open_id), GFP_KERNEL);
|
item.type = s->type;
|
||||||
if (NULL == item) {
|
item.open_id = cx->open_id++;
|
||||||
snd_cx18_unlock(cxsc);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->cx = cx;
|
|
||||||
item->type = s->type;
|
|
||||||
item->open_id = cx->open_id++;
|
|
||||||
|
|
||||||
/* See if the stream is available */
|
/* See if the stream is available */
|
||||||
if (cx18_claim_stream(item, item->type)) {
|
if (cx18_claim_stream(&item, item.type)) {
|
||||||
/* No, it's already in use */
|
/* No, it's already in use */
|
||||||
kfree(item);
|
|
||||||
snd_cx18_unlock(cxsc);
|
snd_cx18_unlock(cxsc);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user