Commit 5e50afb2 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: usbtmc: fix probe error path

commit 2e47c535 upstream.

Make sure to initialise the return value to avoid having allocation
failures going unnoticed when allocating interrupt-endpoint resources.

This prevents use-after-free or worse when the device is later unbound.

Fixes: dbf3e7f6 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.")
Cc: Dave Penkler <dpenkler@gmail.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 73c4e2ed
...@@ -1475,8 +1475,10 @@ static int usbtmc_probe(struct usb_interface *intf, ...@@ -1475,8 +1475,10 @@ static int usbtmc_probe(struct usb_interface *intf,
if (data->iin_ep_present) { if (data->iin_ep_present) {
/* allocate int urb */ /* allocate int urb */
data->iin_urb = usb_alloc_urb(0, GFP_KERNEL); data->iin_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!data->iin_urb) if (!data->iin_urb) {
retcode = -ENOMEM;
goto error_register; goto error_register;
}
/* will reference data in int urb */ /* will reference data in int urb */
kref_get(&data->kref); kref_get(&data->kref);
...@@ -1484,8 +1486,10 @@ static int usbtmc_probe(struct usb_interface *intf, ...@@ -1484,8 +1486,10 @@ static int usbtmc_probe(struct usb_interface *intf,
/* allocate buffer for interrupt in */ /* allocate buffer for interrupt in */
data->iin_buffer = kmalloc(data->iin_wMaxPacketSize, data->iin_buffer = kmalloc(data->iin_wMaxPacketSize,
GFP_KERNEL); GFP_KERNEL);
if (!data->iin_buffer) if (!data->iin_buffer) {
retcode = -ENOMEM;
goto error_register; goto error_register;
}
/* fill interrupt urb */ /* fill interrupt urb */
usb_fill_int_urb(data->iin_urb, data->usb_dev, usb_fill_int_urb(data->iin_urb, data->usb_dev,
......
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