Skip to contentSkip to conversation

serial: icom: dereference after free in load_code()

PATCH New Dan Carpenter 1 participant 1 message Nov 8, 2013

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

PATCH 1/1 serial: icom: dereference after free in load_code()

We use "fw" in the next line after we release it. I've shifted the call to release_firmware() down a couple lines to fix this.

drivers/tty/serial/icom.c +2 -2
index d98e433..6742380 100644
@@ -455,11 +455,11 @@ static void load_code(struct icom_port *icom_port)
 	for (index = 0; index < fw->size; index++)
 		new_page[index] = fw->data[index];
 
-	release_firmware(fw);
-
 	writeb((char) ((fw->size + 16)/16), &icom_port->dram->mac_length);
 	writel(temp_pci, &icom_port->dram->mac_load_addr);
 
+	release_firmware(fw);
+
 	/*Setting the syncReg to 0x80 causes adapter to start downloading
 	   the personality code into adapter instruction RAM.
 	   Once code is loaded, it will begin executing and, based on