Source-Changes-HG archive

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

[src/trunk]: src/sys Fix memory leaks on arp -d and ndp -d for static entries



details:   https://anonhg.NetBSD.org/src/rev/91d32189f482
branches:  trunk
changeset: 321195:91d32189f482
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Mar 06 07:25:27 2018 +0000

description:
Fix memory leaks on arp -d and ndp -d for static entries

We have to delete entries on in_lltable_delete and in6_lltable_delete
unconditionally.  Note that we don't need to worry about LLE_IFADDR because
there is no such entries now.

diffstat:

 sys/net/if_llatbl.c |   4 +++-
 sys/netinet/in.c    |  10 +++-------
 sys/netinet6/in6.c  |  10 +++-------
 3 files changed, 9 insertions(+), 15 deletions(-)

diffs (94 lines):

diff -r 0381abb1d402 -r 91d32189f482 sys/net/if_llatbl.c
--- a/sys/net/if_llatbl.c       Tue Mar 06 07:24:01 2018 +0000
+++ b/sys/net/if_llatbl.c       Tue Mar 06 07:25:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_llatbl.c,v 1.24 2018/03/06 07:24:01 ozaki-r Exp $   */
+/*     $NetBSD: if_llatbl.c,v 1.25 2018/03/06 07:25:27 ozaki-r Exp $   */
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -351,6 +351,8 @@
 
        LLE_WLOCK_ASSERT(lle);
 
+       lle->la_flags |= LLE_DELETED;
+
        if ((lle->la_flags & LLE_LINKED) != 0) {
                llt = lle->lle_tbl;
 
diff -r 0381abb1d402 -r 91d32189f482 sys/netinet/in.c
--- a/sys/netinet/in.c  Tue Mar 06 07:24:01 2018 +0000
+++ b/sys/netinet/in.c  Tue Mar 06 07:25:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.221 2018/03/06 07:24:01 ozaki-r Exp $ */
+/*     $NetBSD: in.c,v 1.222 2018/03/06 07:25:27 ozaki-r Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.221 2018/03/06 07:24:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.222 2018/03/06 07:25:27 ozaki-r Exp $");
 
 #include "arp.h"
 
@@ -2135,7 +2135,6 @@
        }
 
        LLE_WLOCK(lle);
-       lle->la_flags |= LLE_DELETED;
 #ifdef LLTABLE_DEBUG
        {
                char buf[64];
@@ -2144,10 +2143,7 @@
                    __func__, buf, lle);
        }
 #endif
-       if ((lle->la_flags & (LLE_STATIC | LLE_IFADDR)) == LLE_STATIC)
-               llentry_free(lle);
-       else
-               LLE_WUNLOCK(lle);
+       llentry_free(lle);
 
        return (0);
 }
diff -r 0381abb1d402 -r 91d32189f482 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Tue Mar 06 07:24:01 2018 +0000
+++ b/sys/netinet6/in6.c        Tue Mar 06 07:25:27 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.262 2018/03/06 07:24:01 ozaki-r Exp $        */
+/*     $NetBSD: in6.c,v 1.263 2018/03/06 07:25:27 ozaki-r Exp $        */
 /*     $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $   */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.262 2018/03/06 07:24:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.263 2018/03/06 07:25:27 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2549,7 +2549,6 @@
        }
 
        LLE_WLOCK(lle);
-       lle->la_flags |= LLE_DELETED;
 #ifdef LLTABLE_DEBUG
        {
                char buf[64];
@@ -2558,10 +2557,7 @@
                    __func__, buf, lle);
        }
 #endif
-       if ((lle->la_flags & (LLE_STATIC | LLE_IFADDR)) == LLE_STATIC)
-               llentry_free(lle);
-       else
-               LLE_WUNLOCK(lle);
+       llentry_free(lle);
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index