Module Name:    src
Committed By:   bouyer
Date:           Thu Mar 15 18:38:37 UTC 2012

Modified Files:
        src/sys/dev/usb: ehci.c

Log Message:
Do not read array before detecting array overflow, found by gcc -O3


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.187 src/sys/dev/usb/ehci.c:1.188
--- src/sys/dev/usb/ehci.c:1.187	Sun Mar 11 00:34:45 2012
+++ src/sys/dev/usb/ehci.c	Thu Mar 15 18:38:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.187 2012/03/11 00:34:45 mrg Exp $ */
+/*	$NetBSD: ehci.c,v 1.188 2012/03/15 18:38:37 bouyer Exp $ */
 
 /*
  * Copyright (c) 2004-2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.187 2012/03/11 00:34:45 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.188 2012/03/15 18:38:37 bouyer Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2712,14 +2712,14 @@ ehci_alloc_sqtd_chain(struct ehci_pipe *
 			ehci_physaddr_t a = dataphys + i * EHCI_PAGE_SIZE;
 			if (i != 0) /* use offset only in first buffer */
 				a = EHCI_PAGE(a);
-			cur->qtd.qtd_buffer[i] = htole32(a);
-			cur->qtd.qtd_buffer_hi[i] = 0;
 #ifdef DIAGNOSTIC
 			if (i >= EHCI_QTD_NBUFFERS) {
 				printf("ehci_alloc_sqtd_chain: i=%d\n", i);
 				goto nomem;
 			}
 #endif
+			cur->qtd.qtd_buffer[i] = htole32(a);
+			cur->qtd.qtd_buffer_hi[i] = 0;
 		}
 		cur->nextqtd = next;
 		cur->qtd.qtd_next = cur->qtd.qtd_altnext = nextphys;

Reply via email to