diff options
author | Johan Hovold <johan@kernel.org> | 2017-03-14 12:55:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-17 00:22:58 -0400 |
commit | 2e47c53503eb9faff42b3cfa144a833344dd1f89 (patch) | |
tree | 5f5ee146e1e527a37817d5b22a168c4ef7e4bc92 /drivers/usb/class | |
parent | 687e0687f71ec00e0132a21fef802dee88c2f1ad (diff) |
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>
Diffstat (limited to 'drivers/usb/class')
-rw-r--r-- | drivers/usb/class/usbtmc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 5e3446db4513..8fb309a0ff6b 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c | |||
@@ -1476,8 +1476,10 @@ static int usbtmc_probe(struct usb_interface *intf, | |||
1476 | if (data->iin_ep_present) { | 1476 | if (data->iin_ep_present) { |
1477 | /* allocate int urb */ | 1477 | /* allocate int urb */ |
1478 | data->iin_urb = usb_alloc_urb(0, GFP_KERNEL); | 1478 | data->iin_urb = usb_alloc_urb(0, GFP_KERNEL); |
1479 | if (!data->iin_urb) | 1479 | if (!data->iin_urb) { |
1480 | retcode = -ENOMEM; | ||
1480 | goto error_register; | 1481 | goto error_register; |
1482 | } | ||
1481 | 1483 | ||
1482 | /* Protect interrupt in endpoint data until iin_urb is freed */ | 1484 | /* Protect interrupt in endpoint data until iin_urb is freed */ |
1483 | kref_get(&data->kref); | 1485 | kref_get(&data->kref); |
@@ -1485,8 +1487,10 @@ static int usbtmc_probe(struct usb_interface *intf, | |||
1485 | /* allocate buffer for interrupt in */ | 1487 | /* allocate buffer for interrupt in */ |
1486 | data->iin_buffer = kmalloc(data->iin_wMaxPacketSize, | 1488 | data->iin_buffer = kmalloc(data->iin_wMaxPacketSize, |
1487 | GFP_KERNEL); | 1489 | GFP_KERNEL); |
1488 | if (!data->iin_buffer) | 1490 | if (!data->iin_buffer) { |
1491 | retcode = -ENOMEM; | ||
1489 | goto error_register; | 1492 | goto error_register; |
1493 | } | ||
1490 | 1494 | ||
1491 | /* fill interrupt urb */ | 1495 | /* fill interrupt urb */ |
1492 | usb_fill_int_urb(data->iin_urb, data->usb_dev, | 1496 | usb_fill_int_urb(data->iin_urb, data->usb_dev, |