Skip to contentSkip to conversation

serial: ioc3_serial: release resources in error return path

PATCH In review Rahul Ruikar 2 participants 2 messages Sep 29, 2010 – Oct 1, 2010 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: ioc3_serial: release resources in error return path

In ioc3uart_probe()
resources were not released during error return path
- ports[phys_port]

---
 drivers/serial/ioc3_serial.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/serial/ioc3_serial.c +6 -2
index 93de907..1a182cf 100644
@@ -2017,6 +2017,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
 	struct ioc3_port *port;
 	struct ioc3_port *ports[PORTS_PER_CARD];
 	int phys_port;
+	int cnt;
 
 	DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __func__, is, idd));
 
@@ -2044,7 +2045,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
 		if (!port) {
 			printk(KERN_WARNING
 			       "IOC3 serial memory not available for port\n");
-			goto out4;
+			goto out3;
 		}
 		spin_lock_init(&port->ip_lock);
 
@@ -2138,13 +2139,16 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
 	/* register port with the serial core */
 
 	if ((ret = ioc3_serial_core_attach(is, idd)))
-		goto out4;
+		goto out3;
 
 	Num_of_ioc3_cards++;
 
 	return ret;
 
 	/* error exits that give back resources */
+out3:
+	for (cnt = 0; cnt < phys_port; cnt++)
+		kfree(ports[cnt]);
 out4:
 	kfree(card_ptr);
 	return ret;
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 5 lines · Rahul Ruikar

-                       goto out4;
+                       goto out3;

-               goto out4;
+               goto out3;

you changed *all* uses of out4 to out3, so with this patch I see:

drivers/serial/ioc3_serial.c:2152: warning: label ‘out4’ defined but not used

So I dropped the first hunks, and changed the last one to this:

Quoted 6 lines

out4:
+       for (cnt = 0; cnt < phys_port; cnt++)
+               kfree(ports[cnt]);
+
       kfree(card_ptr);
       return ret;

Applied with this change.

Thanks

-Tony