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.
This commit is contained in:
ozaki-r 2018-03-06 07:25:27 +00:00
parent 0e7f921617
commit 9891458159
3 changed files with 9 additions and 15 deletions

View File

@ -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 @@ llentry_free(struct llentry *lle)
LLE_WLOCK_ASSERT(lle);
lle->la_flags |= LLE_DELETED;
if ((lle->la_flags & LLE_LINKED) != 0) {
llt = lle->lle_tbl;

View File

@ -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 @@ in_lltable_delete(struct lltable *llt, u_int flags,
}
LLE_WLOCK(lle);
lle->la_flags |= LLE_DELETED;
#ifdef LLTABLE_DEBUG
{
char buf[64];
@ -2144,10 +2143,7 @@ in_lltable_delete(struct lltable *llt, u_int flags,
__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);
}

View File

@ -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 @@ in6_lltable_delete(struct lltable *llt, u_int flags,
}
LLE_WLOCK(lle);
lle->la_flags |= LLE_DELETED;
#ifdef LLTABLE_DEBUG
{
char buf[64];
@ -2558,10 +2557,7 @@ in6_lltable_delete(struct lltable *llt, u_int flags,
__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;
}