}
mutex_lock(&serial->parent->mutex);
+ /* check for port already opened, if not set the termios */
+ /* The serial->open count needs to be here as hso_serial_close
+ * will be called even if hso_serial_open returns -ENODEV.
+ */
+ serial->open_count++;
result = usb_autopm_get_interface(serial->parent->interface);
if (result < 0)
goto err_out;
tty->driver_data = serial;
serial->tty = tty;
- /* check for port already opened, if not set the termios */
- serial->open_count++;
if (serial->open_count == 1) {
tty->low_latency = 1;
serial->rx_state = RX_IDLE;
u8 usb_gone;
D1("Closing serial port");
+ if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) {
+ D1("invalid serial structure bailing out.\n");
+ return;
+ }
mutex_lock(&serial->parent->mutex);
usb_gone = serial->parent->usb_gone;