Skip to content
Snippets Groups Projects
Commit 3bfcd025 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

net: hso: fix muxed tty registration


commit e8f69b16 upstream.

If resource allocation and registration fail for a muxed tty device
(e.g. if there are no more minor numbers) the driver should not try to
deregister the never-registered (or already-deregistered) tty.

Fix up the error handling to avoid dereferencing a NULL pointer when
attempting to remove the character device.

Fixes: 72dc1c09 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org	# 2.6.27
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 503b2e01
No related branches found
No related tags found
No related merge requests found
...@@ -2713,14 +2713,14 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface, ...@@ -2713,14 +2713,14 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
serial = kzalloc(sizeof(*serial), GFP_KERNEL); serial = kzalloc(sizeof(*serial), GFP_KERNEL);
if (!serial) if (!serial)
goto exit; goto err_free_dev;
hso_dev->port_data.dev_serial = serial; hso_dev->port_data.dev_serial = serial;
serial->parent = hso_dev; serial->parent = hso_dev;
if (hso_serial_common_create if (hso_serial_common_create
(serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE))
goto exit; goto err_free_serial;
serial->tx_data_length--; serial->tx_data_length--;
serial->write_data = hso_mux_serial_write_data; serial->write_data = hso_mux_serial_write_data;
...@@ -2736,11 +2736,9 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface, ...@@ -2736,11 +2736,9 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
/* done, return it */ /* done, return it */
return hso_dev; return hso_dev;
exit: err_free_serial:
if (serial) { kfree(serial);
tty_unregister_device(tty_drv, serial->minor); err_free_dev:
kfree(serial);
}
kfree(hso_dev); kfree(hso_dev);
return NULL; return NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment