Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: hso: fix muxed tty registration

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: 72dc1c096c70 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org # 2.6.27
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Johan Hovold and committed by
David S. Miller
e8f69b16 fc0c0548

+5 -7
+5 -7
drivers/net/usb/hso.c
··· 2719 2719 2720 2720 serial = kzalloc(sizeof(*serial), GFP_KERNEL); 2721 2721 if (!serial) 2722 - goto exit; 2722 + goto err_free_dev; 2723 2723 2724 2724 hso_dev->port_data.dev_serial = serial; 2725 2725 serial->parent = hso_dev; 2726 2726 2727 2727 if (hso_serial_common_create 2728 2728 (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) 2729 - goto exit; 2729 + goto err_free_serial; 2730 2730 2731 2731 serial->tx_data_length--; 2732 2732 serial->write_data = hso_mux_serial_write_data; ··· 2742 2742 /* done, return it */ 2743 2743 return hso_dev; 2744 2744 2745 - exit: 2746 - if (serial) { 2747 - tty_unregister_device(tty_drv, serial->minor); 2748 - kfree(serial); 2749 - } 2745 + err_free_serial: 2746 + kfree(serial); 2747 + err_free_dev: 2750 2748 kfree(hso_dev); 2751 2749 return NULL; 2752 2750