changeset 3943:302736821720

6415231 Galaxy 1 system panics w/BAD TRAP (page fault) in "ohci" due to NULL pointer
author sl147100
date Sun, 01 Apr 2007 22:45:05 -0700
parents c202da1d3c1c
children 75371f172291
files usr/src/uts/common/io/usb/usba/genconsole.c
diffstat 1 files changed, 30 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/usb/usba/genconsole.c	Sat Mar 31 20:04:53 2007 -0700
+++ b/usr/src/uts/common/io/usb/usba/genconsole.c	Sun Apr 01 22:45:05 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
@@ -48,8 +48,21 @@
 {
 	int			ret;
 	usba_device_t		*usba_device;
-	usb_console_info_impl_t	*usb_console_input = kmem_zalloc(
-			sizeof (struct usb_console_info_impl), KM_SLEEP);
+	usba_pipe_handle_data_t	*ph_data;
+	usb_console_info_impl_t	*usb_console_input;
+
+	if (dip == NULL) {
+
+		return (USB_INVALID_ARGS);
+	}
+
+	if (DEVI_IS_DEVICE_REMOVED(dip)) {
+
+		return (USB_FAILURE);
+	}
+
+	usb_console_input = kmem_zalloc(
+	    sizeof (struct usb_console_info_impl), KM_SLEEP);
 
 	/*
 	 * Save the dip
@@ -62,18 +75,30 @@
 	usba_device = usba_get_usba_device(dip);
 
 	/*
+	 * Get ph_data from pipe handle and hold the data
+	 */
+	if ((ph_data = usba_hold_ph_data(pipe_handle)) == NULL) {
+		kmem_free(usb_console_input,
+		    sizeof (struct usb_console_info_impl));
+
+		return (USB_INVALID_PIPE);
+	}
+
+	/*
 	 * Call the lower layer to initialize any state information
 	 */
 	ret = usba_device->usb_hcdi_ops->usba_hcdi_console_input_init(
-		usba_get_ph_data(pipe_handle), state_buf, usb_console_input);
+	    ph_data, state_buf, usb_console_input);
 
 	if (ret != USB_SUCCESS) {
 		kmem_free(usb_console_input,
-			sizeof (struct usb_console_info_impl));
+		    sizeof (struct usb_console_info_impl));
 	} else {
 		*console_input_info = (usb_console_info_t)usb_console_input;
 	}
 
+	usba_release_ph_data((usba_ph_impl_t *)pipe_handle);
+
 	return (ret);
 }