diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-28 05:48:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-28 05:51:30 -0400 |
commit | ab21b63e8aedfc73565dd9cdd51eb338341177cb (patch) | |
tree | 917a36b41513989feabea08e27f1f5f54d46266e /drivers/usb/class | |
parent | decc5360f23e9efe0252094f47f57f254dcbb3a9 (diff) |
Revert "usbtmc: convert to devm_kzalloc"
This reverts commit e6c7efdcb76f11b04e3d3f71c8d764ab75c9423b.
Turns out it was totally wrong. The memory is supposed to be bound to
the kref, as the original code was doing correctly, not the
device/driver binding as the devm_kzalloc() would cause.
This fixes an oops when read would be called after the device was
unbound from the driver.
Reported-by: Ladislav Michl <ladis@linux-mips.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: stable <stable@vger.kernel.org> # 3.12+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/class')
-rw-r--r-- | drivers/usb/class/usbtmc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index da4f2509f567..a6c1fae7d52a 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c | |||
@@ -141,6 +141,7 @@ static void usbtmc_delete(struct kref *kref) | |||
141 | struct usbtmc_device_data *data = to_usbtmc_data(kref); | 141 | struct usbtmc_device_data *data = to_usbtmc_data(kref); |
142 | 142 | ||
143 | usb_put_dev(data->usb_dev); | 143 | usb_put_dev(data->usb_dev); |
144 | kfree(data); | ||
144 | } | 145 | } |
145 | 146 | ||
146 | static int usbtmc_open(struct inode *inode, struct file *filp) | 147 | static int usbtmc_open(struct inode *inode, struct file *filp) |
@@ -1379,7 +1380,7 @@ static int usbtmc_probe(struct usb_interface *intf, | |||
1379 | 1380 | ||
1380 | dev_dbg(&intf->dev, "%s called\n", __func__); | 1381 | dev_dbg(&intf->dev, "%s called\n", __func__); |
1381 | 1382 | ||
1382 | data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); | 1383 | data = kmalloc(sizeof(*data), GFP_KERNEL); |
1383 | if (!data) | 1384 | if (!data) |
1384 | return -ENOMEM; | 1385 | return -ENOMEM; |
1385 | 1386 | ||