Module Name: src
Committed By: rmind
Date: Mon Dec 26 12:44:10 UTC 2016
Modified Files:
src/sys/net/npf: lpm.c
Log Message:
Fix kmem_free() sizes in hashmap_rehash() and lpm_clear().
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/net/npf/lpm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/npf/lpm.c
diff -u src/sys/net/npf/lpm.c:1.1 src/sys/net/npf/lpm.c:1.2
--- src/sys/net/npf/lpm.c:1.1 Fri Dec 9 02:40:38 2016
+++ src/sys/net/npf/lpm.c Mon Dec 26 12:44:10 2016
@@ -31,7 +31,7 @@
#if defined(_KERNEL)
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lpm.c,v 1.1 2016/12/09 02:40:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lpm.c,v 1.2 2016/12/26 12:44:10 rmind Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -117,7 +117,7 @@ lpm_clear(lpm_t *lpm, lpm_dtor_t dtor, v
entry = next;
}
}
- kmem_free(hmap->bucket, hmap->hashsize);
+ kmem_free(hmap->bucket, hmap->hashsize * sizeof(lpm_ent_t *));
hmap->bucket = NULL;
hmap->hashsize = 0;
hmap->nitems = 0;
@@ -158,7 +158,7 @@ hashmap_rehash(lpm_hmap_t *hmap, uint32_
for (hashsize = 1; hashsize < size; hashsize <<= 1) {
continue;
}
- bucket = kmem_zalloc(hashsize * sizeof(*bucket), KM_SLEEP);
+ bucket = kmem_zalloc(hashsize * sizeof(lpm_ent_t *), KM_SLEEP);
if (bucket == NULL)
return false;
for (unsigned n = 0; n < hmap->hashsize; n++) {
@@ -175,7 +175,7 @@ hashmap_rehash(lpm_hmap_t *hmap, uint32_
}
}
if (hmap->bucket)
- kmem_free(hmap->bucket, hmap->hashsize);
+ kmem_free(hmap->bucket, hmap->hashsize * sizeof(lpm_ent_t *));
hmap->bucket = bucket;
hmap->hashsize = hashsize;
return true;