# HG changeset patch # User sl147100 # Date 1175492705 25200 # Node ID 302736821720f06a67b3df7cabec34f38b264d0e # Parent c202da1d3c1c7099b3e0f5fb9f762ccc01277335 6415231 Galaxy 1 system panics w/BAD TRAP (page fault) in "ohci" due to NULL pointer diff -r c202da1d3c1c -r 302736821720 usr/src/uts/common/io/usb/usba/genconsole.c --- 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); }