On Wed, 27 Jul 2016, co...@sdf.org wrote:
Log Message:
If we're going to check for a NULL pointer, do the check before we
dereference it (to get the lock address).
To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/md.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/md.c
diff -u src/sys/dev/md.c:1.76 src/sys/dev/md.c:1.77
--- src/sys/dev/md.c:1.76 Mon Jan 4 16:24:52 2016
+++ src/sys/dev/md.c Wed Jul 27 01:09:44 2016
@@ -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 @@ mdstrategy(struct buf *bp)
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:
goto done; will exit mutex not entered now, I think.
Yup - already fixed.
Well, I had fixed it in my localcount branch, but not on HEAD. It
should be fixed everywhere now.
Thanks for pointing this out.
+------------------+--------------------------+------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+