From: Michael Ellerman Date: Fri, 10 Aug 2012 05:01:23 +0000 (+1000) Subject: kvm tools: Fix crash when /etc/resolv.conf doesn't exist X-Git-Tag: next-20120816~7^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a2a7af4c58f76b5e724f850a9b4b70f49bc5086c;p=karo-tx-linux.git kvm tools: Fix crash when /etc/resolv.conf doesn't exist 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. Acked-by: Asias He Signed-off-by: Michael Ellerman Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/net/uip/dhcp.c b/tools/kvm/net/uip/dhcp.c index e91a7c7a6aca..b17d35239321 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; }