Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Fix a breakout of loops



details:   https://anonhg.NetBSD.org/src/rev/8bbff4d3b8d4
branches:  trunk
changeset: 818961:8bbff4d3b8d4
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Nov 10 03:32:04 2016 +0000

description:
Fix a breakout of loops

As the comment "find first available ipv4 address" indicates,
if an IP address is found, we need to leave the two nested loops,
a loop for an interface list and a loop for IP addresses of
an interface. However, the original code broke away only from
the inner loop.

The original (wrong) behavior was non-critical, which just
returned a non-first IP address. Unfortunately, after applying
psref, the behavior may call psref_acquire twice to a target
with the same psref object, resulting in a kernel panic eventually.

diffstat:

 sys/arch/x86/x86/vmt.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r f050e31ab0b8 -r 8bbff4d3b8d4 sys/arch/x86/x86/vmt.c
--- a/sys/arch/x86/x86/vmt.c    Wed Nov 09 22:01:15 2016 +0000
+++ b/sys/arch/x86/x86/vmt.c    Thu Nov 10 03:32:04 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmt.c,v 1.14 2016/08/01 03:15:30 ozaki-r Exp $ */
+/* $NetBSD: vmt.c,v 1.15 2016/11/10 03:32:04 ozaki-r Exp $ */
 /* $OpenBSD: vmt.c,v 1.11 2011/01/27 21:29:25 dtucker Exp $ */
 
 /*
@@ -825,9 +825,10 @@
 
                                guest_ip = satosin(iface_addr->ifa_addr);
                                ifa_acquire(iface_addr, &psref);
-                               break;
+                               goto got;
                        }
                }
+       got:
                pserialize_read_exit(s);
 
                if (guest_ip != NULL) {



Home | Main Index | Thread Index | Old Index