In uip_dhcp_get_dns() we try to open /etc/resolv.conf. If we fail to
open it we then SEGV trying to fclose() it.

Fix the code to just return directly if we can't open it.

Signed-off-by: Michael Ellerman <[email protected]>
---
 tools/kvm/net/uip/dhcp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/kvm/net/uip/dhcp.c b/tools/kvm/net/uip/dhcp.c
index e91a7c7..b17d352 100644
--- a/tools/kvm/net/uip/dhcp.c
+++ b/tools/kvm/net/uip/dhcp.c
@@ -45,7 +45,7 @@ int uip_dhcp_get_dns(struct uip_info *info)
 
        fp = fopen("/etc/resolv.conf", "r");
        if (!fp)
-               goto out;
+               return ret;
 
        while (!feof(fp)) {
                if (fscanf(fp, "%s %s\n", key, val) != 2)
@@ -62,7 +62,6 @@ int uip_dhcp_get_dns(struct uip_info *info)
                }
        }
 
-out:
        fclose(fp);
        return ret;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to