diff options
author | Amit Choudhary <amit2030@gmail.com> | 2007-03-30 16:48:59 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:45:21 -0400 |
commit | fd51c697dd6111ee4260d8c752ba4d09dc614c3f (patch) | |
tree | cb6bb35c8251adf8f77af97df710adadf99b6034 /drivers/media/video/se401.c | |
parent | 20ec811eddb362f821c6fd57e5449f3ddb80b466 (diff) |
V4L/DVB (5490): Drivers/media/video/se401.c: check kmalloc() return value.
Check the return value of kmalloc() in function se401_start_stream(), in
file drivers/media/video/se401.c.
Signed-off-by: Amit Choudhary <amit2030@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/se401.c')
-rw-r--r-- | drivers/media/video/se401.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c index 038448f5a978..93fb04ed99a0 100644 --- a/drivers/media/video/se401.c +++ b/drivers/media/video/se401.c | |||
@@ -450,6 +450,13 @@ static int se401_start_stream(struct usb_se401 *se401) | |||
450 | } | 450 | } |
451 | for (i=0; i<SE401_NUMSBUF; i++) { | 451 | for (i=0; i<SE401_NUMSBUF; i++) { |
452 | se401->sbuf[i].data=kmalloc(SE401_PACKETSIZE, GFP_KERNEL); | 452 | se401->sbuf[i].data=kmalloc(SE401_PACKETSIZE, GFP_KERNEL); |
453 | if (!se401->sbuf[i].data) { | ||
454 | for(i = i - 1; i >= 0; i--) { | ||
455 | kfree(se401->sbuf[i].data); | ||
456 | se401->sbuf[i].data = NULL; | ||
457 | } | ||
458 | return -ENOMEM; | ||
459 | } | ||
453 | } | 460 | } |
454 | 461 | ||
455 | se401->bayeroffset=0; | 462 | se401->bayeroffset=0; |
@@ -458,13 +465,26 @@ static int se401_start_stream(struct usb_se401 *se401) | |||
458 | se401->scratch_overflow=0; | 465 | se401->scratch_overflow=0; |
459 | for (i=0; i<SE401_NUMSCRATCH; i++) { | 466 | for (i=0; i<SE401_NUMSCRATCH; i++) { |
460 | se401->scratch[i].data=kmalloc(SE401_PACKETSIZE, GFP_KERNEL); | 467 | se401->scratch[i].data=kmalloc(SE401_PACKETSIZE, GFP_KERNEL); |
468 | if (!se401->scratch[i].data) { | ||
469 | for(i = i - 1; i >= 0; i--) { | ||
470 | kfree(se401->scratch[i].data); | ||
471 | se401->scratch[i].data = NULL; | ||
472 | } | ||
473 | goto nomem_sbuf; | ||
474 | } | ||
461 | se401->scratch[i].state=BUFFER_UNUSED; | 475 | se401->scratch[i].state=BUFFER_UNUSED; |
462 | } | 476 | } |
463 | 477 | ||
464 | for (i=0; i<SE401_NUMSBUF; i++) { | 478 | for (i=0; i<SE401_NUMSBUF; i++) { |
465 | urb=usb_alloc_urb(0, GFP_KERNEL); | 479 | urb=usb_alloc_urb(0, GFP_KERNEL); |
466 | if(!urb) | 480 | if(!urb) { |
467 | return -ENOMEM; | 481 | for(i = i - 1; i >= 0; i--) { |
482 | usb_kill_urb(se401->urb[i]); | ||
483 | usb_free_urb(se401->urb[i]); | ||
484 | se401->urb[i] = NULL; | ||
485 | } | ||
486 | goto nomem_scratch; | ||
487 | } | ||
468 | 488 | ||
469 | usb_fill_bulk_urb(urb, se401->dev, | 489 | usb_fill_bulk_urb(urb, se401->dev, |
470 | usb_rcvbulkpipe(se401->dev, SE401_VIDEO_ENDPOINT), | 490 | usb_rcvbulkpipe(se401->dev, SE401_VIDEO_ENDPOINT), |
@@ -482,6 +502,18 @@ static int se401_start_stream(struct usb_se401 *se401) | |||
482 | se401->framecount=0; | 502 | se401->framecount=0; |
483 | 503 | ||
484 | return 0; | 504 | return 0; |
505 | |||
506 | nomem_scratch: | ||
507 | for (i=0; i<SE401_NUMSCRATCH; i++) { | ||
508 | kfree(se401->scratch[i].data); | ||
509 | se401->scratch[i].data = NULL; | ||
510 | } | ||
511 | nomem_sbuf: | ||
512 | for (i=0; i<SE401_NUMSBUF; i++) { | ||
513 | kfree(se401->sbuf[i].data); | ||
514 | se401->sbuf[i].data = NULL; | ||
515 | } | ||
516 | return -ENOMEM; | ||
485 | } | 517 | } |
486 | 518 | ||
487 | static int se401_stop_stream(struct usb_se401 *se401) | 519 | static int se401_stop_stream(struct usb_se401 *se401) |