Skip to content

Commit

Permalink
usb: hso: check for return value in hso_serial_common_create()
Browse files Browse the repository at this point in the history
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=67b2bd0e34f952d0321e
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rustam Kovhaev authored and David S. Miller committed Jul 28, 2020
1 parent 7a9212d commit e911e99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -2261,12 +2261,14 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,

minor = get_free_serial_index();
if (minor < 0)
goto exit;
goto exit2;

/* register our minor number */
serial->parent->dev = tty_port_register_device_attr(&serial->port,
tty_drv, minor, &serial->parent->interface->dev,
serial->parent, hso_serial_dev_groups);
if (IS_ERR(serial->parent->dev))
goto exit2;

/* fill in specific data for later use */
serial->minor = minor;
Expand Down Expand Up @@ -2311,6 +2313,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
return 0;
exit:
hso_serial_tty_unregister(serial);
exit2:
hso_serial_common_free(serial);
return -1;
}
Expand Down

0 comments on commit e911e99

Please sign in to comment.