From 1eb384e3386bce32f2d698665187eadfef4d44f3 Mon Sep 17 00:00:00 2001 From: maxv Date: Thu, 29 Nov 2018 17:40:12 +0000 Subject: [PATCH] Improve my kern_time.c::rev1.192, systematically clear the buffers we get from 'ptimer_pool' to prevent more leaks. --- sys/compat/linux/common/linux_misc_notalpha.c | 5 +++-- sys/kern/kern_time.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/common/linux_misc_notalpha.c b/sys/compat/linux/common/linux_misc_notalpha.c index 3a4ebd508f23..370211ac6b4b 100644 --- a/sys/compat/linux/common/linux_misc_notalpha.c +++ b/sys/compat/linux/common/linux_misc_notalpha.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc_notalpha.c,v 1.109 2014/11/09 17:48:08 maxv Exp $ */ +/* $NetBSD: linux_misc_notalpha.c,v 1.110 2018/11/29 17:40:12 maxv Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.109 2014/11/09 17:48:08 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.110 2018/11/29 17:40:12 maxv Exp $"); /* * Note that we must NOT include "opt_compat_linux32.h" here, @@ -161,6 +161,7 @@ linux_sys_alarm(struct lwp *l, const struct linux_sys_alarm_args *uap, register_ if (spare == NULL) { mutex_spin_exit(&timer_lock); spare = pool_get(&ptimer_pool, PR_WAITOK); + memset(spare, 0, sizeof(*spare)); goto retry; } ptp = spare; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 530f4b3cecf5..0360b8482e30 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.192 2018/11/28 15:10:40 maxv Exp $ */ +/* $NetBSD: kern_time.c,v 1.193 2018/11/29 17:40:12 maxv Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.192 2018/11/28 15:10:40 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.193 2018/11/29 17:40:12 maxv Exp $"); #include #include @@ -1166,6 +1166,7 @@ dosetitimer(struct proc *p, int which, struct itimerval *itvp) if (spare == NULL) { mutex_spin_exit(&timer_lock); spare = pool_get(&ptimer_pool, PR_WAITOK); + memset(spare, 0, sizeof(*spare)); goto retry; } pt = spare;