Pass the same size to kmem_alloc(9) and kmem_free(9), this fixes

the kmem_poison_check panic on DEBUG kernels.
This commit is contained in:
xtraeme 2008-01-29 19:35:05 +00:00
parent f7a8a22745
commit d187549ef6
1 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: aiboost.c,v 1.20 2007/12/13 15:36:29 xtraeme Exp $ */ /* $NetBSD: aiboost.c,v 1.21 2008/01/29 19:35:05 xtraeme Exp $ */
/*- /*-
* Copyright (c) 2007 Juan Romero Pardines * Copyright (c) 2007 Juan Romero Pardines
@ -28,7 +28,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: aiboost.c,v 1.20 2007/12/13 15:36:29 xtraeme Exp $"); __KERNEL_RCSID(0, "$NetBSD: aiboost.c,v 1.21 2008/01/29 19:35:05 xtraeme Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -111,6 +111,7 @@ aiboost_acpi_attach(device_t parent, device_t self, void *aux)
struct acpi_attach_args *aa = aux; struct acpi_attach_args *aa = aux;
ACPI_HANDLE *handl; ACPI_HANDLE *handl;
int i, maxsens, error = 0; int i, maxsens, error = 0;
size_t len;
sc->sc_node = aa->aa_node; sc->sc_node = aa->aa_node;
handl = sc->sc_node->ad_handle; handl = sc->sc_node->ad_handle;
@ -135,8 +136,8 @@ aiboost_acpi_attach(device_t parent, device_t self, void *aux)
DPRINTF(("%s: maxsens=%d\n", __func__, maxsens)); DPRINTF(("%s: maxsens=%d\n", __func__, maxsens));
sc->sc_sme = sysmon_envsys_create(); sc->sc_sme = sysmon_envsys_create();
sc->sc_sensor = kmem_zalloc(sizeof(envsys_data_t) * maxsens, len = sizeof(envsys_data_t) * maxsens;
KM_NOSLEEP); sc->sc_sensor = kmem_zalloc(len, KM_NOSLEEP);
if (!sc->sc_sensor) if (!sc->sc_sensor)
goto bad2; goto bad2;
@ -173,7 +174,7 @@ aiboost_acpi_attach(device_t parent, device_t self, void *aux)
return; return;
bad: bad:
kmem_free(sc->sc_sensor, sizeof(*sc->sc_sensor)); kmem_free(sc->sc_sensor, len);
bad2: bad2:
sysmon_envsys_destroy(sc->sc_sme); sysmon_envsys_destroy(sc->sc_sme);
mutex_destroy(&sc->sc_mtx); mutex_destroy(&sc->sc_mtx);
@ -311,7 +312,7 @@ aiboost_getcomp(ACPI_HANDLE *h, const char *name, struct aiboost_comp **comp)
struct aiboost_comp *c = NULL; struct aiboost_comp *c = NULL;
int i; int i;
const char *str = NULL; const char *str = NULL;
size_t length; size_t length, clen = 0;
status = acpi_eval_struct(h, name, &buf); status = acpi_eval_struct(h, name, &buf);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
@ -331,9 +332,9 @@ aiboost_getcomp(ACPI_HANDLE *h, const char *name, struct aiboost_comp **comp)
goto error; goto error;
} }
c = kmem_zalloc(sizeof(struct aiboost_comp) + clen = sizeof(struct aiboost_comp) + sizeof(struct aiboost_elem) *
sizeof(struct aiboost_elem) * (elem->Integer.Value - 1), (elem->Integer.Value - 1);
KM_NOSLEEP); c = kmem_zalloc(clen, KM_NOSLEEP);
if (!c) if (!c)
goto error; goto error;
@ -405,7 +406,7 @@ error:
if (buf2.Pointer) if (buf2.Pointer)
AcpiOsFree(buf2.Pointer); AcpiOsFree(buf2.Pointer);
if (c) if (c)
kmem_free(c, sizeof(*c)); kmem_free(c, clen);
return AE_BAD_DATA; return AE_BAD_DATA;
} }