diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-10-17 11:39:06 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-10-17 11:39:06 -0300 |
commit | cf13c4422ee8780648413bce1c29b2fecc1bca63 (patch) | |
tree | 64a4ee689f9f42e4076377327c39ad31a5df9095 /linux/drivers/media/video/stv680.c | |
parent | 35f70d440eb3e085baaf535617b1d7233c96a557 (diff) | |
download | mediapointer-dvb-s2-cf13c4422ee8780648413bce1c29b2fecc1bca63.tar.gz mediapointer-dvb-s2-cf13c4422ee8780648413bce1c29b2fecc1bca63.tar.bz2 |
Stv680.c: check kmalloc() return value.
From: Amit Choudhary <amit2030@gmail.com>
Signed-off-by: Amit Choudhary <amit2030@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/stv680.c')
-rw-r--r-- | linux/drivers/media/video/stv680.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/linux/drivers/media/video/stv680.c b/linux/drivers/media/video/stv680.c index f8e9f1cbd..44ff13f36 100644 --- a/linux/drivers/media/video/stv680.c +++ b/linux/drivers/media/video/stv680.c @@ -690,7 +690,7 @@ static int stv680_start_stream (struct usb_stv *stv680) stv680->sbuf[i].data = kmalloc (stv680->rawbufsize, GFP_KERNEL); if (stv680->sbuf[i].data == NULL) { PDEBUG (0, "STV(e): Could not kmalloc raw data buffer %i", i); - return -1; + goto nomem_err; } } @@ -701,7 +701,7 @@ static int stv680_start_stream (struct usb_stv *stv680) stv680->scratch[i].data = kmalloc (stv680->rawbufsize, GFP_KERNEL); if (stv680->scratch[i].data == NULL) { PDEBUG (0, "STV(e): Could not kmalloc raw scratch buffer %i", i); - return -1; + goto nomem_err; } stv680->scratch[i].state = BUFFER_UNUSED; } @@ -709,7 +709,7 @@ static int stv680_start_stream (struct usb_stv *stv680) for (i = 0; i < STV680_NUMSBUF; i++) { urb = usb_alloc_urb (0, GFP_KERNEL); if (!urb) - return -ENOMEM; + goto nomem_err; /* sbuf is urb->transfer_buffer, later gets memcpyed to scratch */ usb_fill_bulk_urb (urb, stv680->udev, @@ -724,6 +724,21 @@ static int stv680_start_stream (struct usb_stv *stv680) stv680->framecount = 0; return 0; + + nomem_err: + for (i = 0; i < STV680_NUMSCRATCH; i++) { + kfree(stv680->scratch[i].data); + stv680->scratch[i].data = NULL; + } + for (i = 0; i < STV680_NUMSBUF; i++) { + usb_kill_urb(stv680->urb[i]); + usb_free_urb(stv680->urb[i]); + stv680->urb[i] = NULL; + kfree(stv680->sbuf[i].data); + stv680->sbuf[i].data = NULL; + } + return -ENOMEM; + } static int stv680_stop_stream (struct usb_stv *stv680) |