summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-11-21 16:14:44 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-11-21 16:14:44 +0000
commit0938e5da3a603b8c340e9d228b80b002916f9df6 (patch)
tree28babe7621dc667aebd0f8623ee48ac6c47688cb
parent9677227ebd472807977e275461fba6c5c4b4e2a9 (diff)
free(9) sizes for bread_cluser().
ok mikeb@, visa@
-rw-r--r--sys/kern/vfs_bio.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 3dcac1eb121..ea42c50f73d 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.186 2018/08/13 15:26:17 visa Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.187 2018/11/21 16:14:43 mpi Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*
@@ -538,7 +538,7 @@ bread_cluster_callback(struct buf *bp)
/* Invalidate read-ahead buffers if read short */
if (bp->b_resid > 0) {
- for (i = 0; xbpp[i] != NULL; i++)
+ for (i = 1; xbpp[i] != NULL; i++)
continue;
for (i = i - 1; i != 0; i--) {
if (xbpp[i]->b_bufsize <= bp->b_resid) {
@@ -558,7 +558,7 @@ bread_cluster_callback(struct buf *bp)
biodone(xbpp[i]);
}
- free(xbpp, M_TEMP, 0);
+ free(xbpp, M_TEMP, (i + 1) * sizeof(*xbpp));
if (ISSET(bp->b_flags, B_ASYNC)) {
brelse(bp);
@@ -603,7 +603,7 @@ bread_cluster(struct vnode *vp, daddr_t blkno, int size, struct buf **rbpp)
if (howmany > maxra)
howmany = maxra;
- xbpp = mallocarray(howmany + 1, sizeof(struct buf *), M_TEMP, M_NOWAIT);
+ xbpp = mallocarray(howmany + 1, sizeof(*xbpp), M_TEMP, M_NOWAIT);
if (xbpp == NULL)
goto out;
@@ -622,7 +622,7 @@ bread_cluster(struct vnode *vp, daddr_t blkno, int size, struct buf **rbpp)
SET(xbpp[i]->b_flags, B_INVAL);
brelse(xbpp[i]);
}
- free(xbpp, M_TEMP, 0);
+ free(xbpp, M_TEMP, (howmany + 1) * sizeof(*xbpp));
goto out;
}
}