USB: usbtmc: fix probe error path

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: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.")
Cc: stable <stable@vger.kernel.org> # 4.6
Cc: Dave Penkler <dpenkler@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Johan Hovold and committed by Greg Kroah-Hartman 2e47c535 687e0687

+6 -2
+6 -2
drivers/usb/class/usbtmc.c
··· 1476 if (data->iin_ep_present) { 1477 /* allocate int urb */ 1478 data->iin_urb = usb_alloc_urb(0, GFP_KERNEL); 1479 - if (!data->iin_urb) 1480 goto error_register; 1481 1482 /* Protect interrupt in endpoint data until iin_urb is freed */ 1483 kref_get(&data->kref); ··· 1487 /* allocate buffer for interrupt in */ 1488 data->iin_buffer = kmalloc(data->iin_wMaxPacketSize, 1489 GFP_KERNEL); 1490 - if (!data->iin_buffer) 1491 goto error_register; 1492 1493 /* fill interrupt urb */ 1494 usb_fill_int_urb(data->iin_urb, data->usb_dev,
··· 1476 if (data->iin_ep_present) { 1477 /* allocate int urb */ 1478 data->iin_urb = usb_alloc_urb(0, GFP_KERNEL); 1479 + if (!data->iin_urb) { 1480 + retcode = -ENOMEM; 1481 goto error_register; 1482 + } 1483 1484 /* Protect interrupt in endpoint data until iin_urb is freed */ 1485 kref_get(&data->kref); ··· 1485 /* allocate buffer for interrupt in */ 1486 data->iin_buffer = kmalloc(data->iin_wMaxPacketSize, 1487 GFP_KERNEL); 1488 + if (!data->iin_buffer) { 1489 + retcode = -ENOMEM; 1490 goto error_register; 1491 + } 1492 1493 /* fill interrupt urb */ 1494 usb_fill_int_urb(data->iin_urb, data->usb_dev,