Commit 9d9f5272 authored by Rustam Kovhaev's avatar Rustam Kovhaev Committed by Kelsey Skunberg

usb: hso: check for return value in hso_serial_common_create()

BugLink: https://bugs.launchpad.net/bugs/1892822

[ Upstream commit e911e99a ]

in case of an error tty_register_device_attr() returns ERR_PTR(),
add IS_ERR() check

Reported-and-tested-by: syzbot+67b2bd0e34f952d0321e@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=67b2bd0e34f952d0321eSigned-off-by: default avatarRustam Kovhaev <rkovhaev@gmail.com>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent da81a3e7
...@@ -2280,12 +2280,14 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, ...@@ -2280,12 +2280,14 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
minor = get_free_serial_index(); minor = get_free_serial_index();
if (minor < 0) if (minor < 0)
goto exit; goto exit2;
/* register our minor number */ /* register our minor number */
serial->parent->dev = tty_port_register_device_attr(&serial->port, serial->parent->dev = tty_port_register_device_attr(&serial->port,
tty_drv, minor, &serial->parent->interface->dev, tty_drv, minor, &serial->parent->interface->dev,
serial->parent, hso_serial_dev_groups); serial->parent, hso_serial_dev_groups);
if (IS_ERR(serial->parent->dev))
goto exit2;
dev = serial->parent->dev; dev = serial->parent->dev;
/* fill in specific data for later use */ /* fill in specific data for later use */
...@@ -2335,6 +2337,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, ...@@ -2335,6 +2337,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
return 0; return 0;
exit: exit:
hso_serial_tty_unregister(serial); hso_serial_tty_unregister(serial);
exit2:
hso_serial_common_free(serial); hso_serial_common_free(serial);
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment