Skip to content

Commit

Permalink
net: hso: fix muxed tty registration
Browse files Browse the repository at this point in the history
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: 72dc1c0 ("HSO: add option hso driver")
Cc: [email protected]	# 2.6.27
Signed-off-by: Johan Hovold <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jhovold authored and davem330 committed Sep 17, 2021
1 parent fc0c054 commit e8f69b1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -2719,14 +2719,14 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,

serial = kzalloc(sizeof(*serial), GFP_KERNEL);
if (!serial)
goto exit;
goto err_free_dev;

hso_dev->port_data.dev_serial = serial;
serial->parent = hso_dev;

if (hso_serial_common_create
(serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE))
goto exit;
goto err_free_serial;

serial->tx_data_length--;
serial->write_data = hso_mux_serial_write_data;
Expand All @@ -2742,11 +2742,9 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
/* done, return it */
return hso_dev;

exit:
if (serial) {
tty_unregister_device(tty_drv, serial->minor);
kfree(serial);
}
err_free_serial:
kfree(serial);
err_free_dev:
kfree(hso_dev);
return NULL;

Expand Down

0 comments on commit e8f69b1

Please sign in to comment.