Skip to content

Commit

Permalink
net/rocker: Plug memory leak in pci_rocker_init()
Browse files Browse the repository at this point in the history
pci_rocker_init() leaks a World when the name more than 9 chars,
then return a negative value directly, doesn't make a correct
cleanup. So add a new goto label to fix it.

Cc: jasowang@redhat.com
Cc: jiri@resnulli.us
Cc: armbru@redhat.com
Cc: f4bug@amsat.org
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
  • Loading branch information
Mao Zhongyi authored and jasowang committed Sep 8, 2017
1 parent 107e4b3 commit 1343a10
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hw/net/rocker/rocker.c
Expand Up @@ -1355,7 +1355,8 @@ static int pci_rocker_init(PCIDevice *dev)
fprintf(stderr,
"rocker: name too long; please shorten to at most %d chars\n",
MAX_ROCKER_NAME_LEN);
return -EINVAL;
err = -EINVAL;
goto err_name_too_long;
}

if (memcmp(&r->fp_start_macaddr, &zero, sizeof(zero)) == 0) {
Expand Down Expand Up @@ -1414,6 +1415,7 @@ static int pci_rocker_init(PCIDevice *dev)

return 0;

err_name_too_long:
err_duplicate:
rocker_msix_uninit(r);
err_msix_init:
Expand Down

0 comments on commit 1343a10

Please sign in to comment.