Skip to contentSkip to conversation

Patch "USB: serial: fix memleak in driver-registration error path" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Sep 2, 2016

Subsystems (3)
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

USB: serial: fix memleak in driver-registration error path

to the 4.4-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:
usb-serial-fix-memleak-in-driver-registration-error-path.patch
and it can be found in the queue-4.4 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 647024a7df36014bbc4479d92d88e6b77c0afcf6 Mon Sep 17 00:00:00 2001

From: Alexey Klimov <[email protected]>
Date: Mon, 8 Aug 2016 02:34:46 +0100
Subject: USB: serial: fix memleak in driver-registration error path

From: Alexey Klimov <[email protected]>

commit 647024a7df36014bbc4479d92d88e6b77c0afcf6 upstream.

udriver struct allocated by kzalloc() will not be freed if usb_register() and next calls fail. This patch fixes this by adding one more step with kfree(udriver) in error path.

---
 drivers/usb/serial/usb-serial.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/usb-serial.c +3 -1
@@ -1432,7 +1432,7 @@ int usb_serial_register_drivers(struct u
 
 	rc = usb_register(udriver);
 	if (rc)
-		return rc;
+		goto failed_usb_register;
 
 	for (sd = serial_drivers; *sd; ++sd) {
 		(*sd)->usb_driver = udriver;
@@ -1450,6 +1450,8 @@ int usb_serial_register_drivers(struct u
 	while (sd-- > serial_drivers)
 		usb_serial_deregister(*sd);
 	usb_deregister(udriver);
+failed_usb_register:
+	kfree(udriver);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(usb_serial_register_drivers);

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

queue-4.4/usb-serial-fix-memleak-in-driver-registration-error-path.patch