Skip to content

Commit ab21b63

Browse files
committed
Revert "usbtmc: convert to devm_kzalloc"
This reverts commit e6c7efd. 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 <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: stable <[email protected]> # 3.12+ Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent decc536 commit ab21b63

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/usb/class/usbtmc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static void usbtmc_delete(struct kref *kref)
141141
struct usbtmc_device_data *data = to_usbtmc_data(kref);
142142

143143
usb_put_dev(data->usb_dev);
144+
kfree(data);
144145
}
145146

146147
static int usbtmc_open(struct inode *inode, struct file *filp)
@@ -1379,7 +1380,7 @@ static int usbtmc_probe(struct usb_interface *intf,
13791380

13801381
dev_dbg(&intf->dev, "%s called\n", __func__);
13811382

1382-
data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
1383+
data = kmalloc(sizeof(*data), GFP_KERNEL);
13831384
if (!data)
13841385
return -ENOMEM;
13851386

0 commit comments

Comments
 (0)