Source-Changes-HG archive

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

[src/trunk]: src/sys/net Fix panic on ifconfig <number>



details:   https://anonhg.NetBSD.org/src/rev/7f2c4f685884
branches:  trunk
changeset: 352107:7f2c4f685884
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Mar 16 08:11:47 2017 +0000

description:
Fix panic on ifconfig <number>

Pointed out by s-yamaguchi@IIJ

diffstat:

 sys/net/if.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 670dcdfccb0e -r 7f2c4f685884 sys/net/if.c
--- a/sys/net/if.c      Thu Mar 16 05:23:56 2017 +0000
+++ b/sys/net/if.c      Thu Mar 16 08:11:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.385 2017/03/14 09:03:08 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.386 2017/03/16 08:11:47 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.385 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.386 2017/03/16 08:11:47 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2594,9 +2594,13 @@
        if (i == IFNAMSIZ || (cp != name && *cp == '\0')) {
                if (unit >= if_indexlim)
                        return NULL;
+               s = pserialize_read_enter();
                ifp = ifindex2ifnet[unit];
                if (ifp == NULL || if_is_deactivated(ifp))
-                       return NULL;
+                       ifp = NULL;
+               if (ifp != NULL)
+                       psref_acquire(psref, &ifp->if_psref, ifnet_psref_class);
+               pserialize_read_exit(s);
                return ifp;
        }
 



Home | Main Index | Thread Index | Old Index