]> git.karo-electronics.de Git - mv-sheeva.git/commit
[media] media, tlg2300: Fix memory leak in alloc_bulk_urbs_generic()
authorJesper Juhl <jj@chaosbits.net>
Sun, 2 Jan 2011 20:57:24 +0000 (17:57 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 Jan 2011 13:45:45 +0000 (11:45 -0200)
commitfd01ad98945073faeb25391489caef4844f265c4
treeb242f6745723c112f35224b6e8cc9e20824e4c12
parent36fd97884daf4e30b556a6c59b58db19a06d58af
[media] media, tlg2300: Fix memory leak in alloc_bulk_urbs_generic()

Hi,

While reading
drivers/media/video/tlg2300/pd-video.c::alloc_bulk_urbs_generic() I
noticed that

 - We don't free the memory allocated to 'urb' if the call to
   usb_alloc_coherent() fails.
 - If the 'num' argument to the function is ever <= 0 we'll return an
   uninitialized variable 'i' to the caller.

The following patch addresses both of the above by a) calling
usb_free_urb() when usb_alloc_coherent() fails and by explicitly
initializing 'i' to zero.
I also moved the variables 'mem' and 'urb' inside the for loop. This does
not actually make any difference, it just seemed more correct to me to let
variables exist only in the innermost scope they are used.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/tlg2300/pd-video.c