Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/nvdimm/nvdimm.c
Show First 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | for (bit_ffc_at((bitstr_t *)nv->label_index->free, 0, num_labels, &n); | ||||
&n)) { | &n)) { | ||||
read_label(nv, n); | read_label(nv, n); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
struct nvdimm_dev * | struct nvdimm_dev * | ||||
nvdimm_find_by_handle(nfit_handle_t nv_handle) | nvdimm_find_by_handle(nfit_handle_t nv_handle) | ||||
{ | { | ||||
bwidawsk: I think you need to free the buffer on each loop, not just at the end. You could potentially… | |||||
struct nvdimm_dev *res; | struct nvdimm_dev *res; | ||||
device_t *dimms; | device_t *dimms; | ||||
int i, error, num_dimms; | int i, error, num_dimms; | ||||
res = NULL; | res = NULL; | ||||
error = devclass_get_devices(nvdimm_devclass, &dimms, &num_dimms); | error = devclass_get_devices(nvdimm_devclass, &dimms, &num_dimms); | ||||
if (error != 0) | if (error != 0) | ||||
return (NULL); | return (NULL); | ||||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | for (i = spas; i < spas + num_spas; i++) { | ||||
spa = malloc(sizeof(struct SPA_mapping), M_NVDIMM, | spa = malloc(sizeof(struct SPA_mapping), M_NVDIMM, | ||||
M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
error = nvdimm_spa_init(spa, *i, spa_type); | error = nvdimm_spa_init(spa, *i, spa_type); | ||||
if (error != 0) { | if (error != 0) { | ||||
nvdimm_spa_fini(spa); | nvdimm_spa_fini(spa); | ||||
free(spa, M_NVDIMM); | free(spa, M_NVDIMM); | ||||
break; | break; | ||||
} | } | ||||
nvdimm_create_namespaces(spa, nfitbl); | |||||
SLIST_INSERT_HEAD(&dev->spas, spa, link); | SLIST_INSERT_HEAD(&dev->spas, spa, link); | ||||
} | } | ||||
free(spas, M_NVDIMM); | free(spas, M_NVDIMM); | ||||
return (error); | return (error); | ||||
} | } | ||||
static char *nvdimm_root_id[] = {"ACPI0012", NULL}; | static char *nvdimm_root_id[] = {"ACPI0012", NULL}; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct nvdimm_root_dev *root; | struct nvdimm_root_dev *root; | ||||
struct SPA_mapping *spa, *next; | struct SPA_mapping *spa, *next; | ||||
device_t *children; | device_t *children; | ||||
int i, error, num_children; | int i, error, num_children; | ||||
root = device_get_softc(dev); | root = device_get_softc(dev); | ||||
SLIST_FOREACH_SAFE(spa, &root->spas, link, next) { | SLIST_FOREACH_SAFE(spa, &root->spas, link, next) { | ||||
nvdimm_destroy_namespaces(spa); | |||||
nvdimm_spa_fini(spa); | nvdimm_spa_fini(spa); | ||||
SLIST_REMOVE_HEAD(&root->spas, link); | SLIST_REMOVE_HEAD(&root->spas, link); | ||||
free(spa, M_NVDIMM); | free(spa, M_NVDIMM); | ||||
} | } | ||||
error = bus_generic_detach(dev); | error = bus_generic_detach(dev); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
error = device_get_children(dev, &children, &num_children); | error = device_get_children(dev, &children, &num_children); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |
I think you need to free the buffer on each loop, not just at the end. You could potentially statically allocate the buffer, but I've never actually tried to do this myself.