From: oga Date: Sun, 17 Aug 2008 21:31:38 +0000 (+0000) Subject: Check that the driver properly initialised before allowing agp_acquire() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9d238d47f932bb30e6e7fecd4b2dc50ab4f5d857;p=openbsd Check that the driver properly initialised before allowing agp_acquire() to succeed. Inspired by Tobias Ulmer, thanks! --- diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index e61894f9307..54100016da3 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp.c,v 1.24 2008/07/12 17:31:06 oga Exp $ */ +/* $OpenBSD: agp.c,v 1.25 2008/08/17 21:31:38 oga Exp $ */ /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -751,6 +751,9 @@ agp_acquire_helper(void *dev, enum agp_acquire_state state) { struct agp_softc *sc = (struct agp_softc *)dev; + if (sc->sc_chipc == NULL) + return (EINVAL); + if (sc->sc_state != AGP_ACQUIRE_FREE) return (EBUSY); sc->sc_state = state; @@ -965,8 +968,7 @@ agp_unbind_memory(void *dev, void *handle) } void -agp_memory_info(void *dev, void *handle, struct - agp_memory_info *mi) +agp_memory_info(void *dev, void *handle, struct agp_memory_info *mi) { struct agp_memory *mem = (struct agp_memory *) handle;