Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb don't access memory outside the array bounds.



details:   https://anonhg.NetBSD.org/src/rev/04d472970891
branches:  trunk
changeset: 780314:04d472970891
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jul 20 02:23:35 2012 +0000

description:
don't access memory outside the array bounds.

diffstat:

 sys/dev/usb/usb.c |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (37 lines):

diff -r 9b39b21d6eb1 -r 04d472970891 sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Fri Jul 20 02:14:01 2012 +0000
+++ b/sys/dev/usb/usb.c Fri Jul 20 02:23:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.c,v 1.132 2012/07/17 10:33:46 cegger Exp $ */
+/*     $NetBSD: usb.c,v 1.133 2012/07/20 02:23:35 christos Exp $       */
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.132 2012/07/17 10:33:46 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.133 2012/07/20 02:23:35 christos Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usb.h"
@@ -362,15 +362,14 @@
 void
 usb_rem_task(usbd_device_handle dev, struct usb_task *task)
 {
-       struct usb_taskq *taskq;
 
-       taskq = &usb_taskq[task->queue];
-       mutex_enter(&taskq->lock);
        if (task->queue != -1) {
+               struct usb_taskq *taskq = &usb_taskq[task->queue];
+               mutex_enter(&taskq->lock);
                TAILQ_REMOVE(&taskq->tasks, task, next);
                task->queue = -1;
+               mutex_exit(&taskq->lock);
        }
-       mutex_exit(&taskq->lock);
 }
 
 void



Home | Main Index | Thread Index | Old Index