Skip to contentSkip to conversation

Memleak in KOBIL USB Smart Card Terminal Driver

PATCH Applied Oleg Drokin 2 participants 2 messages Mar 12, 2003 – Mar 14, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello!

There is a memleak on error exit path in KOBIL USB Smart Card Terminal Driver in both current 2.4 and 2.5.
See the patch.
Found with help of smatch + enhanced unfree script.

Bye,
Oleg

===== drivers/usb/serial/kobil_sct.c 1.2 vs edited =====

drivers/usb/serial/kobil_sct.c +2 -0
@@ -254,6 +254,7 @@
 		port->write_urb = usb_alloc_urb(0);  
 		if (!port->write_urb) {
 			dbg("%s - port %d usb_alloc_urb failed", __FUNCTION__, port->number);
+			kfree(transfer_buffer);
 			return -1;
 		}
 	}
@@ -261,6 +262,7 @@
 	// allocate memory for write_urb transfer buffer
 	port->write_urb->transfer_buffer = (unsigned char *) kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL);
 	if (! port->write_urb->transfer_buffer) {
+		kfree(transfer_buffer);
 		return -1;
 	} 
 
Applied
#1 lore raw
Quoted 6 lines · Oleg Drokin

Hello!

There is a memleak on error exit path in KOBIL USB Smart Card Terminal Driver in both current 2.4 and 2.5.
See the patch.
Found with help of smatch + enhanced unfree script.

Applied to both my 2.4 and 2.5 trees, thanks.

greg k-h