Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Take care not to dereference a NULL softc.



details:   https://anonhg.NetBSD.org/src/rev/d798ea0735ca
branches:  trunk
changeset: 751000:d798ea0735ca
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Thu Jan 21 02:14:42 2010 +0000

description:
Take care not to dereference a NULL softc.

diffstat:

 sys/dev/md.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r 681440a32655 -r d798ea0735ca sys/dev/md.c
--- a/sys/dev/md.c      Thu Jan 21 01:59:09 2010 +0000
+++ b/sys/dev/md.c      Thu Jan 21 02:14:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.61 2009/10/22 20:15:45 snj Exp $      */
+/*     $NetBSD: md.c,v 1.62 2010/01/21 02:14:42 dyoung 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.61 2009/10/22 20:15:45 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.62 2010/01/21 02:14:42 dyoung Exp $");
 
 #include "opt_md.h"
 #include "opt_tftproot.h"
@@ -324,7 +324,7 @@
 
        sc = device_lookup_private(&md_cd, MD_UNIT(dev));
 
-       if (sc->sc_type == MD_UNCONFIGURED)
+       if (sc == NULL || sc->sc_type == MD_UNCONFIGURED)
                return ENXIO;
 
        return (physio(mdstrategy, NULL, dev, B_READ, minphys, uio));
@@ -337,7 +337,7 @@
 
        sc = device_lookup_private(&md_cd, MD_UNIT(dev));
 
-       if (sc->sc_type == MD_UNCONFIGURED)
+       if (sc == NULL || sc->sc_type == MD_UNCONFIGURED)
                return ENXIO;
 
        return (physio(mdstrategy, NULL, dev, B_WRITE, minphys, uio));
@@ -356,7 +356,7 @@
 
        sc = device_lookup_private(&md_cd, MD_UNIT(bp->b_dev));
 
-       if (sc->sc_type == MD_UNCONFIGURED) {
+       if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) {
                bp->b_error = ENXIO;
                goto done;
        }
@@ -409,7 +409,8 @@
        struct md_softc *sc;
        struct md_conf *umd;
 
-       sc = device_lookup_private(&md_cd, MD_UNIT(dev));
+       if ((sc = device_lookup_private(&md_cd, MD_UNIT(dev))) == NULL)
+               return ENXIO;
 
        /* If this is not the raw partition, punt! */
        if (DISKPART(dev) != RAW_PART)



Home | Main Index | Thread Index | Old Index