Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] drivers/media/dvb/dvb-usb/usb-urb.c: adjust array index

Convert array index from the loop bound to the loop index.

A simplified version of the semantic patch that fixes this problem is as

// <smpl>
@@
expression e1,e2,ar;
@@

for(e1 = 0; e1 < e2; e1++) { <...
ar[
- e2
+ e1
]
...> }
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Julia Lawall and committed by
Mauro Carvalho Chehab
eb28dc39 93165b77

+2 -2
+2 -2
drivers/media/dvb/dvb-usb/usb-urb.c
··· 148 148 if (!stream->urb_list[i]) { 149 149 deb_mem("not enough memory for urb_alloc_urb!.\n"); 150 150 for (j = 0; j < i; j++) 151 - usb_free_urb(stream->urb_list[i]); 151 + usb_free_urb(stream->urb_list[j]); 152 152 return -ENOMEM; 153 153 } 154 154 usb_fill_bulk_urb( stream->urb_list[i], stream->udev, ··· 181 181 if (!stream->urb_list[i]) { 182 182 deb_mem("not enough memory for urb_alloc_urb!\n"); 183 183 for (j = 0; j < i; j++) 184 - usb_free_urb(stream->urb_list[i]); 184 + usb_free_urb(stream->urb_list[j]); 185 185 return -ENOMEM; 186 186 } 187 187