aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/stv680.c
diff options
context:
space:
mode:
authorAmit Choudhary <amit2030@gmail.com>2006-10-17 10:39:06 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-12-10 05:50:57 -0500
commitc85f49d49f437605550322bd2739af18230cf85b (patch)
tree9dfd65ed18982bafeb1f810ba28e20782f9e7bad /drivers/media/video/stv680.c
parentfe16af26c849eb75134855c7be22352f1a15844c (diff)
V4L/DVB (4761): Stv680.c: check kmalloc() return value.
Signed-off-by: Amit Choudhary <amit2030@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/stv680.c')
-rw-r--r--drivers/media/video/stv680.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 6d1ef1e2e8ef..a1ec3aca3f91 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -687,7 +687,7 @@ static int stv680_start_stream (struct usb_stv *stv680)
687 stv680->sbuf[i].data = kmalloc (stv680->rawbufsize, GFP_KERNEL); 687 stv680->sbuf[i].data = kmalloc (stv680->rawbufsize, GFP_KERNEL);
688 if (stv680->sbuf[i].data == NULL) { 688 if (stv680->sbuf[i].data == NULL) {
689 PDEBUG (0, "STV(e): Could not kmalloc raw data buffer %i", i); 689 PDEBUG (0, "STV(e): Could not kmalloc raw data buffer %i", i);
690 return -1; 690 goto nomem_err;
691 } 691 }
692 } 692 }
693 693
@@ -698,7 +698,7 @@ static int stv680_start_stream (struct usb_stv *stv680)
698 stv680->scratch[i].data = kmalloc (stv680->rawbufsize, GFP_KERNEL); 698 stv680->scratch[i].data = kmalloc (stv680->rawbufsize, GFP_KERNEL);
699 if (stv680->scratch[i].data == NULL) { 699 if (stv680->scratch[i].data == NULL) {
700 PDEBUG (0, "STV(e): Could not kmalloc raw scratch buffer %i", i); 700 PDEBUG (0, "STV(e): Could not kmalloc raw scratch buffer %i", i);
701 return -1; 701 goto nomem_err;
702 } 702 }
703 stv680->scratch[i].state = BUFFER_UNUSED; 703 stv680->scratch[i].state = BUFFER_UNUSED;
704 } 704 }
@@ -706,7 +706,7 @@ static int stv680_start_stream (struct usb_stv *stv680)
706 for (i = 0; i < STV680_NUMSBUF; i++) { 706 for (i = 0; i < STV680_NUMSBUF; i++) {
707 urb = usb_alloc_urb (0, GFP_KERNEL); 707 urb = usb_alloc_urb (0, GFP_KERNEL);
708 if (!urb) 708 if (!urb)
709 return -ENOMEM; 709 goto nomem_err;
710 710
711 /* sbuf is urb->transfer_buffer, later gets memcpyed to scratch */ 711 /* sbuf is urb->transfer_buffer, later gets memcpyed to scratch */
712 usb_fill_bulk_urb (urb, stv680->udev, 712 usb_fill_bulk_urb (urb, stv680->udev,
@@ -721,6 +721,21 @@ static int stv680_start_stream (struct usb_stv *stv680)
721 721
722 stv680->framecount = 0; 722 stv680->framecount = 0;
723 return 0; 723 return 0;
724
725 nomem_err:
726 for (i = 0; i < STV680_NUMSCRATCH; i++) {
727 kfree(stv680->scratch[i].data);
728 stv680->scratch[i].data = NULL;
729 }
730 for (i = 0; i < STV680_NUMSBUF; i++) {
731 usb_kill_urb(stv680->urb[i]);
732 usb_free_urb(stv680->urb[i]);
733 stv680->urb[i] = NULL;
734 kfree(stv680->sbuf[i].data);
735 stv680->sbuf[i].data = NULL;
736 }
737 return -ENOMEM;
738
724} 739}
725 740
726static int stv680_stop_stream (struct usb_stv *stv680) 741static int stv680_stop_stream (struct usb_stv *stv680)