Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Always check index against array bound; keep onl...



details:   https://anonhg.NetBSD.org/src/rev/efd45e282da2
branches:  trunk
changeset: 778117:efd45e282da2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Mar 17 11:45:00 2012 +0000

description:
Always check index against array bound; keep only the printf under
DIAGNOSTIC. Suggested by matthew green

diffstat:

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

diffs (33 lines):

diff -r 12f38c42ef7b -r efd45e282da2 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Sat Mar 17 11:15:42 2012 +0000
+++ b/sys/dev/usb/ehci.c        Sat Mar 17 11:45:00 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.188 2012/03/15 18:38:37 bouyer Exp $ */
+/*     $NetBSD: ehci.c,v 1.189 2012/03/17 11:45:00 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.188 2012/03/15 18:38:37 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.189 2012/03/17 11:45:00 bouyer Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -2712,12 +2712,12 @@
                        ehci_physaddr_t a = dataphys + i * EHCI_PAGE_SIZE;
                        if (i != 0) /* use offset only in first buffer */
                                a = EHCI_PAGE(a);
+                       if (i >= EHCI_QTD_NBUFFERS) {
 #ifdef DIAGNOSTIC
-                       if (i >= EHCI_QTD_NBUFFERS) {
                                printf("ehci_alloc_sqtd_chain: i=%d\n", i);
+#endif
                                goto nomem;
                        }
-#endif
                        cur->qtd.qtd_buffer[i] = htole32(a);
                        cur->qtd.qtd_buffer_hi[i] = 0;
                }



Home | Main Index | Thread Index | Old Index