summaryrefslogtreecommitdiff
path: root/sys/dev/usb/ugen.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2011-10-14 12:50:45 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2011-10-14 12:50:45 +0000
commit498643d81af3bb411b0e09da1ad82f8cd777ee46 (patch)
tree807930ec77f8c9959eae8fbba475c81d620f7908 /sys/dev/usb/ugen.c
parente6ec4078b1f63fbea52cfacb7fce422aec3293d1 (diff)
Return EINVAL when there's no config descriptor for a given index.
Problem reported by ajacoutot@ ok deraadt@, kettenis@, krw@
Diffstat (limited to 'sys/dev/usb/ugen.c')
-rw-r--r--sys/dev/usb/ugen.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index d042e4526fc..cc9c69f13c3 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ugen.c,v 1.66 2011/07/03 15:47:17 matthew Exp $ */
+/* $OpenBSD: ugen.c,v 1.67 2011/10/14 12:50:44 mpi Exp $ */
/* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */
/* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -1169,6 +1169,8 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd,
int error;
cdesc = ugen_get_cdesc(sc, fd->ufd_config_index, &len);
+ if (cdesc == NULL)
+ return (EINVAL);
if (len > fd->ufd_size)
len = fd->ufd_size;
iov.iov_base = (caddr_t)fd->ufd_data;