diff options
author | nate <nate@FreeBSD.org> | 1997-01-05 06:29:40 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1997-01-05 06:29:40 +0000 |
commit | 0f44d3fe50b9eaaa4f592b8667e29a7a2e2587b8 (patch) | |
tree | d14ac7f9dfd5de21b97d992195e17bd047d73d46 /sys/i386/isa | |
parent | a2603abeb3ce303895e670ae04cf715c298b5562 (diff) | |
download | FreeBSD-src-0f44d3fe50b9eaaa4f592b8667e29a7a2e2587b8.zip FreeBSD-src-0f44d3fe50b9eaaa4f592b8667e29a7a2e2587b8.tar.gz |
Fix for PR/2333 - psm0 panics if no mouse attached:
The problem is that `psmopen()' doesn't validate a pointer before
using it.
Submitted by: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Diffstat (limited to 'sys/i386/isa')
-rw-r--r-- | sys/i386/isa/psm.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/i386/isa/psm.c b/sys/i386/isa/psm.c index 2709038..c6afe54 100644 --- a/sys/i386/isa/psm.c +++ b/sys/i386/isa/psm.c @@ -19,7 +19,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: psm.c,v 1.31 1996/11/28 17:18:56 phk Exp $ + * $Id: psm.c,v 1.32 1996/12/01 19:05:50 sos Exp $ */ /* @@ -508,6 +508,8 @@ psmprobe(struct isa_device *dvp) if (unit >= NPSM) return (0); + psm_softc[unit] = NULL; + sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT); bzero(sc, sizeof *sc); @@ -745,6 +747,9 @@ psmattach(struct isa_device *dvp) int unit = dvp->id_unit; struct psm_softc *sc = psm_softc[unit]; + if (sc == NULL) /* shouldn't happen */ + return (0); + /* initial operation mode */ sc->mode.accelfactor = PSM_ACCEL; sc->mode.protocol = MOUSE_PROTO_PS2; @@ -786,7 +791,7 @@ psmopen(dev_t dev, int flag, int fmt, struct proc *p) /* Get device data */ sc = psm_softc[unit]; - if ((sc->state & PSM_VALID) == 0) + if ((sc == NULL) || (sc->state & PSM_VALID) == 0) /* the device is no longer valid/functioning */ return (ENXIO); ioport = sc->addr; |