summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchl <chl@openbsd.org>2013-11-14 18:09:39 +0000
committerchl <chl@openbsd.org>2013-11-14 18:09:39 +0000
commitdb0d640fbc558856609c9c94e4968fd0e78b580e (patch)
tree61428b9af7a097761a45bc51a7201ab9b71ceeed
parentImprovements for address assignment and related issues in IPv6CP. (diff)
downloadwireguard-openbsd-db0d640fbc558856609c9c94e4968fd0e78b580e.tar.xz
wireguard-openbsd-db0d640fbc558856609c9c94e4968fd0e78b580e.zip
Use (N * sizeof(struct klist)) instead of (N * sizeof(struct klist *))
when malloc'ing struct klist *. Similar diff found upstream: http://svnweb.freebsd.org/base?view=revision&revision=197575 Found by LLVM/Clang Static Analyzer. ok tedu@ krw@ guenther@
-rw-r--r--sys/kern/kern_event.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index e5f429d1e49..b7f2c8fe5cc 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.52 2013/09/14 01:35:00 guenther Exp $ */
+/* $OpenBSD: kern_event.c,v 1.53 2013/11/14 18:09:39 chl Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -1020,12 +1020,12 @@ knote_attach(struct knote *kn, struct filedesc *fdp)
size = fdp->fd_knlistsize;
while (size <= kn->kn_id)
size += KQEXTENT;
- list = malloc(size * sizeof(struct klist *), M_TEMP, M_WAITOK);
+ list = malloc(size * sizeof(struct klist), M_TEMP, M_WAITOK);
bcopy((caddr_t)fdp->fd_knlist, (caddr_t)list,
- fdp->fd_knlistsize * sizeof(struct klist *));
+ fdp->fd_knlistsize * sizeof(struct klist));
bzero((caddr_t)list +
- fdp->fd_knlistsize * sizeof(struct klist *),
- (size - fdp->fd_knlistsize) * sizeof(struct klist *));
+ fdp->fd_knlistsize * sizeof(struct klist),
+ (size - fdp->fd_knlistsize) * sizeof(struct klist));
if (fdp->fd_knlist != NULL)
free(fdp->fd_knlist, M_TEMP);
fdp->fd_knlistsize = size;