blob: 475af09af998c7c34190e6a24f7d29ff5c5e3af3 [file] [log] [blame]
From 2a2746caac815371808b752fbea6ac3385c8519f Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Tue, 14 Mar 2017 17:55:46 +0100
Subject: [PATCH] USB: usbtmc: fix probe error path
commit 2e47c53503eb9faff42b3cfa144a833344dd1f89 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: 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>
[PG: 4.8 code base doesn't need added {} hence different diffstat.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index e228b52303cd..b6e207d6af9d 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1477,6 +1477,7 @@ static int usbtmc_probe(struct usb_interface *intf,
data->iin_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!data->iin_urb) {
dev_err(&intf->dev, "Failed to allocate int urb\n");
+ retcode = -ENOMEM;
goto error_register;
}
@@ -1488,6 +1489,7 @@ static int usbtmc_probe(struct usb_interface *intf,
GFP_KERNEL);
if (!data->iin_buffer) {
dev_err(&intf->dev, "Failed to allocate int buf\n");
+ retcode = -ENOMEM;
goto error_register;
}
--
2.12.0