diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-03-15 20:03:08 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-03-15 20:03:08 +0000 |
commit | 7a98474e0906ac069d94837486659e4625c3cf41 (patch) | |
tree | e6f4d0c586aa8b01085c657132c319cb6f998c96 /sys | |
parent | b9a2c51f2cb93f4b6b2de48dc3ca86e1eef33511 (diff) |
Entries in cd_devs[] may be NULL, so be sure to check for them in your
device open() function.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/isa/joy.c | 4 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/asc.c | 6 | ||||
-rw-r--r-- | sys/arch/sparc/dev/flash.c | 4 | ||||
-rw-r--r-- | sys/arch/sparc/dev/scf.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/wdt.c | 6 |
5 files changed, 16 insertions, 9 deletions
diff --git a/sys/arch/i386/isa/joy.c b/sys/arch/i386/isa/joy.c index 9f1466e8b96..317d0e0957c 100644 --- a/sys/arch/i386/isa/joy.c +++ b/sys/arch/i386/isa/joy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: joy.c,v 1.10 2002/06/02 22:49:59 deraadt Exp $ */ +/* $OpenBSD: joy.c,v 1.11 2006/03/15 20:03:04 miod Exp $ */ /* $NetBSD: joy.c,v 1.3 1996/05/05 19:46:15 christos Exp $ */ /*- @@ -69,6 +69,8 @@ joyopen(dev, flag, mode, p) return (ENXIO); sc = joy_cd.cd_devs[unit]; + if (sc == NULL) + return (ENXIO); if (sc->timeout[i]) return EBUSY; diff --git a/sys/arch/mac68k/dev/asc.c b/sys/arch/mac68k/dev/asc.c index 9e196a90e3e..b11bbeba0a7 100644 --- a/sys/arch/mac68k/dev/asc.c +++ b/sys/arch/mac68k/dev/asc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asc.c,v 1.22 2006/01/22 18:37:56 miod Exp $ */ +/* $OpenBSD: asc.c,v 1.23 2006/03/15 20:03:06 miod Exp $ */ /* $NetBSD: asc.c,v 1.20 1997/02/24 05:47:33 scottr Exp $ */ /* @@ -196,9 +196,11 @@ ascopen(dev, flag, mode, p) int unit; unit = ASCUNIT(dev); - sc = asc_cd.cd_devs[unit]; if (unit >= asc_cd.cd_ndevs) return (ENXIO); + sc = asc_cd.cd_devs[unit]; + if (sc == NULL) + return (ENXIO); if (sc->sc_open) return (EBUSY); sc->sc_open = 1; diff --git a/sys/arch/sparc/dev/flash.c b/sys/arch/sparc/dev/flash.c index 5f3611f9440..769d21450a9 100644 --- a/sys/arch/sparc/dev/flash.c +++ b/sys/arch/sparc/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.4 2006/03/04 12:38:58 miod Exp $ */ +/* $OpenBSD: flash.c,v 1.5 2006/03/15 20:03:06 miod Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -125,6 +125,8 @@ flashopen(dev, flags, mode, p) if (card >= flash_cd.cd_ndevs) return (ENXIO); sc = flash_cd.cd_devs[card]; + if (sc == NULL) + return (ENXIO); if (sc->sc_open) return (EBUSY); sc->sc_open = 1; diff --git a/sys/arch/sparc/dev/scf.c b/sys/arch/sparc/dev/scf.c index 4c3780fc33a..9d67cd4b138 100644 --- a/sys/arch/sparc/dev/scf.c +++ b/sys/arch/sparc/dev/scf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scf.c,v 1.9 2006/03/04 12:38:58 miod Exp $ */ +/* $OpenBSD: scf.c,v 1.10 2006/03/15 20:03:06 miod Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -153,8 +153,9 @@ scfopen(dev, flags, mode, p) if (card >= scf_cd.cd_ndevs) return (ENXIO); - sc = scf_cd.cd_devs[card]; + if (sc == NULL) + return (ENXIO); if (sc->sc_open) return (EBUSY); diff --git a/sys/dev/pci/wdt.c b/sys/dev/pci/wdt.c index 1e261081833..6c032f191c0 100644 --- a/sys/dev/pci/wdt.c +++ b/sys/dev/pci/wdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wdt.c,v 1.6 2005/09/11 18:17:08 mickey Exp $ */ +/* $OpenBSD: wdt.c,v 1.7 2006/03/15 20:03:07 miod Exp $ */ /*- * Copyright (c) 1998,1999 Alex Nash @@ -217,8 +217,8 @@ wdtattach (parent, self, aux) int wdtopen (dev_t dev, int flags, int fmt, struct proc *p) { - if (UNIT(dev) >= wdt_cd.cd_ndevs) - return(ENXIO); + if (UNIT(dev) >= wdt_cd.cd_ndevs || wdt_cd.cd_devs[UNIT(dev)] == NULL) + return (ENXIO); return(0); } |