aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-05-01 09:31:12 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-05-14 01:54:09 -0400
commit3f98387efa9333c5765d36e144c47c107d6ba64a (patch)
treeb5c8f515aecf306b0e0b6087458d221d9411f6cb /drivers/media/video/cx18
parent6a4a79355bfa9ae6977556595a68f2e3a0e143f7 (diff)
V4L/DVB (7854): cx18/ivtv: improve and fix out-of-memory handling
- don't show kernel backtrace when the allocation of the buffers fails: the normal ivtv/cx18 messages are clear enough and the backtrace scares users. - fix cleanup after the buffer allocation fails (caused kernel panic). Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx18')
-rw-r--r--drivers/media/video/cx18/cx18-driver.c4
-rw-r--r--drivers/media/video/cx18/cx18-queue.c6
-rw-r--r--drivers/media/video/cx18/cx18-streams.c13
-rw-r--r--drivers/media/video/cx18/cx18-streams.h2
4 files changed, 14 insertions, 11 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 7813380dce3f..9453223a3dea 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -805,7 +805,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
805 return 0; 805 return 0;
806 806
807free_streams: 807free_streams:
808 cx18_streams_cleanup(cx); 808 cx18_streams_cleanup(cx, 1);
809free_irq: 809free_irq:
810 free_irq(cx->dev->irq, (void *)cx); 810 free_irq(cx->dev->irq, (void *)cx);
811free_i2c: 811free_i2c:
@@ -908,7 +908,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
908 908
909 cx18_halt_firmware(cx); 909 cx18_halt_firmware(cx);
910 910
911 cx18_streams_cleanup(cx); 911 cx18_streams_cleanup(cx, 1);
912 912
913 exit_cx18_i2c(cx); 913 exit_cx18_i2c(cx);
914 914
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index 65af1bb507ca..4ef6996b2048 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -239,12 +239,12 @@ int cx18_stream_alloc(struct cx18_stream *s)
239 239
240 /* allocate stream buffers. Initially all buffers are in q_free. */ 240 /* allocate stream buffers. Initially all buffers are in q_free. */
241 for (i = 0; i < s->buffers; i++) { 241 for (i = 0; i < s->buffers; i++) {
242 struct cx18_buffer *buf = 242 struct cx18_buffer *buf = kzalloc(sizeof(struct cx18_buffer),
243 kzalloc(sizeof(struct cx18_buffer), GFP_KERNEL); 243 GFP_KERNEL|__GFP_NOWARN);
244 244
245 if (buf == NULL) 245 if (buf == NULL)
246 break; 246 break;
247 buf->buf = kmalloc(s->buf_size, GFP_KERNEL); 247 buf->buf = kmalloc(s->buf_size, GFP_KERNEL|__GFP_NOWARN);
248 if (buf->buf == NULL) { 248 if (buf->buf == NULL) {
249 kfree(buf); 249 kfree(buf);
250 break; 250 break;
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index afb141b2027a..4ca9d847f1b1 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -218,7 +218,7 @@ int cx18_streams_setup(struct cx18 *cx)
218 return 0; 218 return 0;
219 219
220 /* One or more streams could not be initialized. Clean 'em all up. */ 220 /* One or more streams could not be initialized. Clean 'em all up. */
221 cx18_streams_cleanup(cx); 221 cx18_streams_cleanup(cx, 0);
222 return -ENOMEM; 222 return -ENOMEM;
223} 223}
224 224
@@ -296,12 +296,12 @@ int cx18_streams_register(struct cx18 *cx)
296 return 0; 296 return 0;
297 297
298 /* One or more streams could not be initialized. Clean 'em all up. */ 298 /* One or more streams could not be initialized. Clean 'em all up. */
299 cx18_streams_cleanup(cx); 299 cx18_streams_cleanup(cx, 1);
300 return -ENOMEM; 300 return -ENOMEM;
301} 301}
302 302
303/* Unregister v4l2 devices */ 303/* Unregister v4l2 devices */
304void cx18_streams_cleanup(struct cx18 *cx) 304void cx18_streams_cleanup(struct cx18 *cx, int unregister)
305{ 305{
306 struct video_device *vdev; 306 struct video_device *vdev;
307 int type; 307 int type;
@@ -319,8 +319,11 @@ void cx18_streams_cleanup(struct cx18 *cx)
319 319
320 cx18_stream_free(&cx->streams[type]); 320 cx18_stream_free(&cx->streams[type]);
321 321
322 /* Unregister device */ 322 /* Unregister or release device */
323 video_unregister_device(vdev); 323 if (unregister)
324 video_unregister_device(vdev);
325 else
326 video_device_release(vdev);
324 } 327 }
325} 328}
326 329
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h
index 8c7ba7d2fa79..f327e947b24f 100644
--- a/drivers/media/video/cx18/cx18-streams.h
+++ b/drivers/media/video/cx18/cx18-streams.h
@@ -24,7 +24,7 @@
24u32 cx18_find_handle(struct cx18 *cx); 24u32 cx18_find_handle(struct cx18 *cx);
25int cx18_streams_setup(struct cx18 *cx); 25int cx18_streams_setup(struct cx18 *cx);
26int cx18_streams_register(struct cx18 *cx); 26int cx18_streams_register(struct cx18 *cx);
27void cx18_streams_cleanup(struct cx18 *cx); 27void cx18_streams_cleanup(struct cx18 *cx, int unregister);
28 28
29/* Capture related */ 29/* Capture related */
30int cx18_start_v4l2_encode_stream(struct cx18_stream *s); 30int cx18_start_v4l2_encode_stream(struct cx18_stream *s);