Skip to contentSkip to conversation

Patch "Revert "usbtmc: convert to devm_kzalloc"" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Oct 6, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

Revert "usbtmc: convert to devm_kzalloc"

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
revert-usbtmc-convert-to-devm_kzalloc.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From ab21b63e8aedfc73565dd9cdd51eb338341177cb Mon Sep 17 00:00:00 2001

From: Greg Kroah-Hartman <[email protected]>
Date: Wed, 28 Sep 2016 11:48:44 +0200
Subject: Revert "usbtmc: convert to devm_kzalloc"

From: Greg Kroah-Hartman <[email protected]>

commit ab21b63e8aedfc73565dd9cdd51eb338341177cb upstream.

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.

---
 drivers/usb/class/usbtmc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/class/usbtmc.c +2 -1
@@ -141,6 +141,7 @@ static void usbtmc_delete(struct kref *k
 	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)
@@ -1379,7 +1380,7 @@ static int usbtmc_probe(struct usb_inter
 
 	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;
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/usb-misc-legousbtower-fix-null-pointer-deference.patch queue-4.8/usb-usbip-vudc-fix-left-shift-overflow.patch queue-4.8/alsa-hda-adding-one-more-alc255-pin-definition-for-headset-problem.patch queue-4.8/revert-usbtmc-convert-to-devm_kzalloc.patch queue-4.8/usb-serial-cp210x-add-id-for-a-juniper-console.patch queue-4.8/arm64-debug-avoid-resetting-stepping-state-machine-when-tif_singlestep.patch queue-4.8/staging-fbtft-fix-bug-in-fbtft-core.patch queue-4.8/using-bug_on-as-an-assert-is-_never_-acceptable.patch