Skip to content

Commit

Permalink
Revert "usbtmc: convert to devm_kzalloc"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gregkh committed Sep 28, 2016
1 parent decc536 commit ab21b63
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usb/class/usbtmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ static void usbtmc_delete(struct kref *kref)
struct usbtmc_device_data *data = to_usbtmc_data(kref);

usb_put_dev(data->usb_dev);
kfree(data);
}

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

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

data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
data = kmalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;

Expand Down

0 comments on commit ab21b63

Please sign in to comment.