diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-03-20 13:14:03 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-03-20 13:14:03 +0000 |
commit | 00d5730cfa9eba06b56bbbe6e06754bae134d697 (patch) | |
tree | 6baa9f23ec1bdac1e604ca19e078dc705d7749a1 /sys | |
parent | 424bafeee6cdf0c7b8cad002411e5d9efad0ac85 (diff) |
Always check if softraid0 is NULL before dereferencing it.
Avoids panic on reboot when softraid has been disabled.
Discovered by, diagnosed, first diff from & fix tested by Scott
Nicholas.
ok bluhm@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/softraid.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 50ef9d655bc..bca68aa55f6 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.421 2022/01/09 05:42:37 jsg Exp $ */ +/* $OpenBSD: softraid.c,v 1.422 2022/03/20 13:14:02 krw Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -1508,11 +1508,11 @@ sr_map_root(void) u_char duid[8]; int i; - DNPRINTF(SR_D_MISC, "%s: sr_map_root\n", DEVNAME(sc)); - if (sc == NULL) return; + DNPRINTF(SR_D_MISC, "%s: sr_map_root\n", DEVNAME(sc)); + bzero(duid, sizeof(duid)); if (bcmp(rootduid, duid, sizeof(duid)) == 0) { DNPRINTF(SR_D_MISC, "%s: root duid is zero\n", DEVNAME(sc)); @@ -4538,6 +4538,9 @@ sr_quiesce(void) struct sr_softc *sc = softraid0; struct sr_discipline *sd, *nsd; + if (sc == NULL) + return; + /* Shutdown disciplines in reverse attach order. */ TAILQ_FOREACH_REVERSE_SAFE(sd, &sc->sc_dis_list, sr_discipline_list, sd_link, nsd) @@ -4550,6 +4553,9 @@ sr_shutdown(int dying) struct sr_softc *sc = softraid0; struct sr_discipline *sd; + if (sc == NULL) + return; + DNPRINTF(SR_D_MISC, "%s: sr_shutdown\n", DEVNAME(sc)); /* |