summaryrefslogtreecommitdiffstats
path: root/sys/dev/softraid.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2010-03-28 09:13:55 +0000
committerjsing <jsing@openbsd.org>2010-03-28 09:13:55 +0000
commit88a227d932e756137d1caa149949dd8bb880d19c (patch)
tree22afc7240f58dbe4acc72ee7b29d7aa6f8166ccb /sys/dev/softraid.c
parentReplace a scsi_done() call with sr_scsi_done() which fixes a missing (diff)
downloadwireguard-openbsd-88a227d932e756137d1caa149949dd8bb880d19c.tar.xz
wireguard-openbsd-88a227d932e756137d1caa149949dd8bb880d19c.zip
Avoid potential null dereferences in ioctl paths.
Found by jsg@ using the clang static analyser. ok marco@
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r--sys/dev/softraid.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 9c0aee7ea98..13b818951e9 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.199 2010/03/28 09:08:32 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.200 2010/03/28 09:13:55 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2079,6 +2079,9 @@ sr_ioctl_vol(struct sr_softc *sc, struct bioc_vol *bv)
if (vol != bv->bv_volid)
continue;
+ if (sc->sc_dis[i] == NULL)
+ goto done;
+
sd = sc->sc_dis[i];
bv->bv_status = sd->sd_vol_status;
bv->bv_size = sd->sd_meta->ssdi.ssd_size << DEV_BSHIFT;
@@ -2143,6 +2146,9 @@ sr_ioctl_disk(struct sr_softc *sc, struct bioc_disk *bd)
if (vol != bd->bd_volid)
continue;
+ if (sc->sc_dis[i] == NULL)
+ goto done;
+
id = bd->bd_diskid;
if (id < sc->sc_dis[i]->sd_meta->ssdi.ssd_chunk_no)
@@ -2271,7 +2277,7 @@ sr_chunk_in_use(struct sr_softc *sc, dev_t dev)
/* See if chunk is already in use. */
for (i = 0; i < SR_MAXSCSIBUS; i++) {
- if (!sc->sc_dis[i])
+ if (sc->sc_dis[i] == NULL)
continue;
sd = sc->sc_dis[i];
for (c = 0; c < sd->sd_meta->ssdi.ssd_chunk_no; c++) {