Skip to contentSkip to conversation

usb: sn9c102_core free urb cleanup

PATCH Luca Risolia 2 participants 2 messages Nov 14, 2006

lore
Share & tools
lore
#0 lore raw
Quoted 16 lines

Hello,

- usb_free_urb() cleanup

drivers/media/video/sn9c102/sn9c102_core.c 2006-11-06 19:57:35.000000000 +0100 renamed from drivers/media/video/sn9c102/sn9c102_core.c 2006-11-06 17:07:45.000000000 +0100 +0 -0
@@ -775,7 +775,7 @@ static int sn9c102_start_transfer(struct
       return 0;
 

free_urbs:

drivers/media/video/sn9c102/sn9c102_core.c 2006-11-06 19:57:35.000000000 +0100 renamed from drivers/media/video/sn9c102/sn9c102_core.c 2006-11-06 17:07:45.000000000 +0100 +1 -1
-       for (i = 0; (i < SN9C102_URBS) &&  cam->urb[i]; i++)
+       for (i = 0; i < SN9C102_URBS; i++)
               usb_free_urb(cam->urb[i]);
Quoted 1 line

free_buffers:

This patch might cause usb_free_urb() to fail if not all the URBs have been allocated successfully: in this case, the original loop stops as soon as cam->urb[i] == NULL (where NULL is given from the failed allocation), while in the second loop there might be a not null cam->urb[i+n] pointing to an URB that has already been deallocated elsewhere.

The same bug is present in PATCH 12/33.

Best regards,
Luca Risolia

#1 lore raw

Hello Luca,

Quoted 18 lines
Quoted 16 lines

- usb_free_urb() cleanup

--- linux-2.6.19-rc4-orig/drivers/media/video/sn9c102/sn9c102_core.c

2006-11-06 17:07:45.000000000 +0100 +++
linux-2.6.19-rc4/drivers/media/video/sn9c102/sn9c102_core.c 2006-11-06
19:57:35.000000000 +0100 @@ -775,7 +775,7 @@ static int
sn9c102_start_transfer(struct
       return 0;

free_urbs:

(quoted diff) +1 -1
-       for (i = 0; (i < SN9C102_URBS) &&  cam->urb[i]; i++)
+       for (i = 0; i < SN9C102_URBS; i++)
               usb_free_urb(cam->urb[i]);
Quoted 1 line

free_buffers:

Quoted 7 lines

This patch might cause usb_free_urb() to fail if not all the URBs have been allocated successfully: in this case, the original loop stops as soon as cam->urb[i] == NULL (where NULL is given from the failed allocation), while in the second loop there might be a not null cam->urb[i+n] pointing to an URB that has already been deallocated elsewhere.

The same bug is present in PATCH 12/33.

Err ... you are right :/ In most drivers urb pointers get zeroed right after deallocation. Here they don't. So my patches might cause what you described.

Andrew can you please drop these two patches?

usb-zc0301_core-free-urb-cleanup.patch
usb-sn9c102_core-free-urb-cleanup.patch

Thanks.

Signature · 3 lines
Regards,

	Mariusz Kozlowski