From cbaed85b4cabc2ad1091180ceeb94e2e109e43d8 Mon Sep 17 00:00:00 2001 From: maxv Date: Mon, 22 Jun 2020 16:39:56 +0000 Subject: [PATCH] pfil_psz gets dropped by the compiler because it is unused if !NET_MPSAFE, so add an #ifdef around it, not to leak memory. Found by kLSan. --- sys/net/pfil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/net/pfil.c b/sys/net/pfil.c index 68c413eea510..63cf1ce4a75b 100644 --- a/sys/net/pfil.c +++ b/sys/net/pfil.c @@ -1,4 +1,4 @@ -/* $NetBSD: pfil.c,v 1.38 2020/04/27 23:35:40 nat Exp $ */ +/* $NetBSD: pfil.c,v 1.39 2020/06/22 16:39:56 maxv Exp $ */ /* * Copyright (c) 2013 Mindaugas Rasiukevicius @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.38 2020/04/27 23:35:40 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.39 2020/06/22 16:39:56 maxv Exp $"); #if defined(_KERNEL_OPT) #include "opt_net_mpsafe.h" @@ -86,13 +86,17 @@ static LIST_HEAD(, pfil_head) pfil_head_list __read_mostly = static kmutex_t pfil_mtx __cacheline_aligned; static struct psref_class *pfil_psref_class __read_mostly; +#ifdef NET_MPSAFE static pserialize_t pfil_psz; +#endif void pfil_init(void) { mutex_init(&pfil_mtx, MUTEX_DEFAULT, IPL_NONE); +#ifdef NET_MPSAFE pfil_psz = pserialize_create(); +#endif pfil_psref_class = psref_class_create("pfil", IPL_SOFTNET); }