Source-Changes-HG archive

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

[src/trunk]: src/sys/dev If we're going to check for a NULL pointer, do the c...



details:   https://anonhg.NetBSD.org/src/rev/8947b89ce4e2
branches:  trunk
changeset: 346669:8947b89ce4e2
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Jul 27 01:09:44 2016 +0000

description:
If we're going to check for a NULL pointer, do the check before we
dereference it (to get the lock address).

diffstat:

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

diffs (34 lines):

diff -r 88608e9fe0de -r 8947b89ce4e2 sys/dev/md.c
--- a/sys/dev/md.c      Tue Jul 26 11:08:59 2016 +0000
+++ b/sys/dev/md.c      Wed Jul 27 01:09:44 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.76 2016/01/04 16:24:52 hannken Exp $  */
+/*     $NetBSD: md.c,v 1.77 2016/07/27 01:09:44 pgoyette Exp $ */
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76 2016/01/04 16:24:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.77 2016/07/27 01:09:44 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -414,13 +414,13 @@
 
        sc = device_lookup_private(&md_cd, MD_UNIT(bp->b_dev));
 
-       mutex_enter(&sc->sc_lock);
-
        if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) {
                bp->b_error = ENXIO;
                goto done;
        }
 
+       mutex_enter(&sc->sc_lock);
+
        switch (sc->sc_type) {
 #if MEMORY_DISK_SERVER
        case MD_UMEM_SERVER:



Home | Main Index | Thread Index | Old Index