Module Name:    src
Committed By:   snj
Date:           Tue Mar 24 20:59:29 UTC 2009

Modified Files:
        src/sys/dev/usb [netbsd-5]: ugen.c

Log Message:
Pull up following revision(s) (requested by drochner in ticket #603):
        sys/dev/usb/ugen.c: revision 1.102
Putting a device into the unconfigured state by an ioctl seems legitimate,
so check for a non-NULL configuration descriptor before dereferencing.
Should fix a crash reported by Nicolas Joly per PR kern/41048.
(It still doesn't look good that the ioctl which unconfigures the device
returns EIO -- either it is legitimate or it isn't -- but since this
is a pullup candidate I don't dare to change user visible behaviour.)


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.99.8.1 src/sys/dev/usb/ugen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.99 src/sys/dev/usb/ugen.c:1.99.8.1
--- src/sys/dev/usb/ugen.c:1.99	Sat May 24 16:40:58 2008
+++ src/sys/dev/usb/ugen.c	Tue Mar 24 20:59:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.99 2008/05/24 16:40:58 cube Exp $	*/
+/*	$NetBSD: ugen.c,v 1.99.8.1 2009/03/24 20:59:29 snj Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.99 2008/05/24 16:40:58 cube Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.99.8.1 2009/03/24 20:59:29 snj Exp $");
 
 #include "opt_ugen_bulk_ra_wb.h"
 #include "opt_compat_netbsd.h"
@@ -283,6 +283,7 @@
 ugen_set_config(struct ugen_softc *sc, int configno)
 {
 	usbd_device_handle dev = sc->sc_udev;
+	usb_config_descriptor_t *cdesc;
 	usbd_interface_handle iface;
 	usb_endpoint_descriptor_t *ed;
 	struct ugen_endpoint *sce;
@@ -307,7 +308,8 @@
 		}
 
 	/* Avoid setting the current value. */
-	if (usbd_get_config_descriptor(dev)->bConfigurationValue != configno) {
+	cdesc = usbd_get_config_descriptor(dev);
+	if (!cdesc || cdesc->bConfigurationValue != configno) {
 		err = usbd_set_config_no(dev, configno, 1);
 		if (err)
 			return (err);

Reply via email to