summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2008-01-14 01:23:54 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2008-01-14 01:23:54 +0000
commitc25ece3d323aafe5e147e8fdc7ca2dfe61538100 (patch)
treee8b7aa77267ed55513660ef26a8be1bacb158d98 /sys/dev
parent0f556121912cfb23ee871e2fc29d358cb76deb3d (diff)
protect against an invalid device index possibly leading to kernel
crash. inspired by deanna's similar bug fix in ac97. ok ratchov
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/envy.c5
-rw-r--r--sys/dev/pci/sv.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c
index 3a2c25f08ce..7b56074de4d 100644
--- a/sys/dev/pci/envy.c
+++ b/sys/dev/pci/envy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envy.c,v 1.4 2007/12/08 10:01:28 ratchov Exp $ */
+/* $OpenBSD: envy.c,v 1.5 2008/01/14 01:23:53 jakemsr Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -840,6 +840,9 @@ envy_query_devinfo(void *self, struct mixer_devinfo *dev)
};
/* XXX: define AudioCsource */
+ if (dev->index < 0)
+ return ENXIO;
+
dev->prev = dev->next = AUDIO_MIXER_LAST;
if (dev->index < ENVY_MIX_OUTSRC) {
dev->type = AUDIO_MIXER_CLASS;
diff --git a/sys/dev/pci/sv.c b/sys/dev/pci/sv.c
index 78a2888cec8..76be6bf66d6 100644
--- a/sys/dev/pci/sv.c
+++ b/sys/dev/pci/sv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sv.c,v 1.22 2007/11/05 00:17:28 jakemsr Exp $ */
+/* $OpenBSD: sv.c,v 1.23 2008/01/14 01:23:53 jakemsr Exp $ */
/*
* Copyright (c) 1998 Constantine Paul Sapuntzakis
@@ -1027,6 +1027,9 @@ sv_query_devinfo(addr, dip)
mixer_devinfo_t *dip;
{
+ if (dip->index < 0)
+ return (ENXIO);
+
/* It's a class */
if (dip->index <= SV_LAST_CLASS) {
dip->type = AUDIO_MIXER_CLASS;