Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Do not read array before detecting array overflo...



details:   https://anonhg.NetBSD.org/src/rev/9f916171bba2
branches:  trunk
changeset: 778090:9f916171bba2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Mar 15 18:38:37 2012 +0000

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

diffstat:

 sys/dev/usb/ehci.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r 0badd4461a27 -r 9f916171bba2 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Thu Mar 15 18:37:43 2012 +0000
+++ b/sys/dev/usb/ehci.c        Thu Mar 15 18:38:37 2012 +0000
@@ -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_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;



Home | Main Index | Thread Index | Old Index