mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
Fix error handling in net_client_init() (Mark McLoughlin)
We weren't freeing the name string everywhere. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7144 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
efb816c9a8
commit
771f133989
1 changed files with 16 additions and 10 deletions
24
net.c
24
net.c
|
@ -1610,7 +1610,8 @@ int net_client_init(const char *device, const char *p)
|
||||||
|
|
||||||
if (idx == -1 || nb_nics >= MAX_NICS) {
|
if (idx == -1 || nb_nics >= MAX_NICS) {
|
||||||
fprintf(stderr, "Too Many NICs\n");
|
fprintf(stderr, "Too Many NICs\n");
|
||||||
return -1;
|
ret = -1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
nd = &nd_table[idx];
|
nd = &nd_table[idx];
|
||||||
macaddr = nd->macaddr;
|
macaddr = nd->macaddr;
|
||||||
|
@ -1624,7 +1625,8 @@ int net_client_init(const char *device, const char *p)
|
||||||
if (get_param_value(buf, sizeof(buf), "macaddr", p)) {
|
if (get_param_value(buf, sizeof(buf), "macaddr", p)) {
|
||||||
if (parse_macaddr(macaddr, buf) < 0) {
|
if (parse_macaddr(macaddr, buf) < 0) {
|
||||||
fprintf(stderr, "invalid syntax for ethernet address\n");
|
fprintf(stderr, "invalid syntax for ethernet address\n");
|
||||||
return -1;
|
ret = -1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_param_value(buf, sizeof(buf), "model", p)) {
|
if (get_param_value(buf, sizeof(buf), "model", p)) {
|
||||||
|
@ -1665,7 +1667,8 @@ int net_client_init(const char *device, const char *p)
|
||||||
devname++;
|
devname++;
|
||||||
if (port < 1 || port > 65535) {
|
if (port < 1 || port > 65535) {
|
||||||
fprintf(stderr, "vmchannel wrong port number\n");
|
fprintf(stderr, "vmchannel wrong port number\n");
|
||||||
return -1;
|
ret = -1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
vmc = malloc(sizeof(struct VMChannel));
|
vmc = malloc(sizeof(struct VMChannel));
|
||||||
snprintf(name, 20, "vmchannel%ld", port);
|
snprintf(name, 20, "vmchannel%ld", port);
|
||||||
|
@ -1673,7 +1676,8 @@ int net_client_init(const char *device, const char *p)
|
||||||
if (!vmc->hd) {
|
if (!vmc->hd) {
|
||||||
fprintf(stderr, "qemu: could not open vmchannel device"
|
fprintf(stderr, "qemu: could not open vmchannel device"
|
||||||
"'%s'\n", devname);
|
"'%s'\n", devname);
|
||||||
return -1;
|
ret = -1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
vmc->port = port;
|
vmc->port = port;
|
||||||
slirp_add_exec(3, vmc->hd, 4, port);
|
slirp_add_exec(3, vmc->hd, 4, port);
|
||||||
|
@ -1687,7 +1691,8 @@ int net_client_init(const char *device, const char *p)
|
||||||
char ifname[64];
|
char ifname[64];
|
||||||
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
|
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
|
||||||
fprintf(stderr, "tap: no interface name\n");
|
fprintf(stderr, "tap: no interface name\n");
|
||||||
return -1;
|
ret = -1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
vlan->nb_host_devs++;
|
vlan->nb_host_devs++;
|
||||||
ret = tap_win32_init(vlan, device, name, ifname);
|
ret = tap_win32_init(vlan, device, name, ifname);
|
||||||
|
@ -1734,7 +1739,8 @@ int net_client_init(const char *device, const char *p)
|
||||||
ret = net_socket_mcast_init(vlan, device, name, buf);
|
ret = net_socket_mcast_init(vlan, device, name, buf);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unknown socket options: %s\n", p);
|
fprintf(stderr, "Unknown socket options: %s\n", p);
|
||||||
return -1;
|
ret = -1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
vlan->nb_host_devs++;
|
vlan->nb_host_devs++;
|
||||||
} else
|
} else
|
||||||
|
@ -1764,13 +1770,13 @@ int net_client_init(const char *device, const char *p)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unknown network device: %s\n", device);
|
fprintf(stderr, "Unknown network device: %s\n", device);
|
||||||
if (name)
|
ret = -1;
|
||||||
free(name);
|
goto out;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "Could not initialize device '%s'\n", device);
|
fprintf(stderr, "Could not initialize device '%s'\n", device);
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
if (name)
|
if (name)
|
||||||
free(name);
|
free(name);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue