Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuraQ-0005Kj-3a for qemu-devel@nongnu.org; Fri, 17 Apr 2009 13:10:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuraP-0005KC-EH for qemu-devel@nongnu.org; Fri, 17 Apr 2009 13:10:45 -0400 Received: from [199.232.76.173] (port=55436 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuraP-0005K3-6v for qemu-devel@nongnu.org; Fri, 17 Apr 2009 13:10:45 -0400 Received: from savannah.gnu.org ([199.232.41.3]:36451 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuraO-0001uq-Nx for qemu-devel@nongnu.org; Fri, 17 Apr 2009 13:10:44 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LuraO-0004gn-4X for qemu-devel@nongnu.org; Fri, 17 Apr 2009 17:10:44 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LuraN-0004gj-UC for qemu-devel@nongnu.org; Fri, 17 Apr 2009 17:10:44 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Fri, 17 Apr 2009 17:10:43 +0000 Subject: [Qemu-devel] [7144] Fix error handling in net_client_init() (Mark McLoughlin) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7144 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7144 Author: aliguori Date: 2009-04-17 17:10:43 +0000 (Fri, 17 Apr 2009) Log Message: ----------- Fix error handling in net_client_init() (Mark McLoughlin) We weren't freeing the name string everywhere. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/net.c Modified: trunk/net.c =================================================================== --- trunk/net.c 2009-04-17 17:10:39 UTC (rev 7143) +++ trunk/net.c 2009-04-17 17:10:43 UTC (rev 7144) @@ -1610,7 +1610,8 @@ if (idx == -1 || nb_nics >= MAX_NICS) { fprintf(stderr, "Too Many NICs\n"); - return -1; + ret = -1; + goto out; } nd = &nd_table[idx]; macaddr = nd->macaddr; @@ -1624,7 +1625,8 @@ if (get_param_value(buf, sizeof(buf), "macaddr", p)) { if (parse_macaddr(macaddr, buf) < 0) { fprintf(stderr, "invalid syntax for ethernet address\n"); - return -1; + ret = -1; + goto out; } } if (get_param_value(buf, sizeof(buf), "model", p)) { @@ -1664,8 +1666,9 @@ port = strtol(p, &devname, 10); devname++; if (port < 1 || port > 65535) { - fprintf(stderr, "vmchannel wrong port number\n"); - return -1; + fprintf(stderr, "vmchannel wrong port number\n"); + ret = -1; + goto out; } vmc = malloc(sizeof(struct VMChannel)); snprintf(name, 20, "vmchannel%ld", port); @@ -1673,7 +1676,8 @@ if (!vmc->hd) { fprintf(stderr, "qemu: could not open vmchannel device" "'%s'\n", devname); - return -1; + ret = -1; + goto out; } vmc->port = port; slirp_add_exec(3, vmc->hd, 4, port); @@ -1687,7 +1691,8 @@ char ifname[64]; if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { fprintf(stderr, "tap: no interface name\n"); - return -1; + ret = -1; + goto out; } vlan->nb_host_devs++; ret = tap_win32_init(vlan, device, name, ifname); @@ -1734,7 +1739,8 @@ ret = net_socket_mcast_init(vlan, device, name, buf); } else { fprintf(stderr, "Unknown socket options: %s\n", p); - return -1; + ret = -1; + goto out; } vlan->nb_host_devs++; } else @@ -1764,13 +1770,13 @@ #endif { fprintf(stderr, "Unknown network device: %s\n", device); - if (name) - free(name); - return -1; + ret = -1; + goto out; } if (ret < 0) { fprintf(stderr, "Could not initialize device '%s'\n", device); } +out: if (name) free(name); return ret;