Module Name: src Committed By: dyoung Date: Thu Jan 21 02:14:42 UTC 2010
Modified Files: src/sys/dev: md.c Log Message: Take care not to dereference a NULL softc. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 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.61 src/sys/dev/md.c:1.62 --- src/sys/dev/md.c:1.61 Thu Oct 22 20:15:45 2009 +++ src/sys/dev/md.c Thu Jan 21 02:14:42 2010 @@ -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)