Commit f79e5b43 authored by Swann Perarnau's avatar Swann Perarnau
Browse files

[fix] area_binding should create the binding

As we cannot find out in advance the binding an area uses, it is not
possible to use a correctly allocated pointer to aml_area_binding.

Fixes a segfault we observed outside of current unit-tests.
parent 1e0d24b8
......@@ -104,7 +104,7 @@ struct aml_area_ops {
void (*release)(struct aml_area_data *, void *);
void *(*mmap)(struct aml_area_data *, void *ptr, size_t);
int (*available)(struct aml_area_data *);
int (*binding)(struct aml_area_data *, struct aml_binding *);
int (*binding)(struct aml_area_data *, struct aml_binding **);
};
struct aml_area {
......@@ -182,7 +182,7 @@ struct aml_area_linux_mbind_ops {
int aml_area_linux_mbind_setdata(struct aml_area_linux_mbind_data *, int,
unsigned long *);
int aml_area_linux_mbind_generic_binding(struct aml_area_linux_mbind_data *,
struct aml_binding *);
struct aml_binding **);
int aml_area_linux_mbind_regular_pre_bind(struct aml_area_linux_mbind_data *);
int aml_area_linux_mbind_regular_post_bind(struct aml_area_linux_mbind_data *,
void *, size_t);
......@@ -275,7 +275,7 @@ void *aml_area_acquire(struct aml_area *, size_t);
void aml_area_release(struct aml_area *, void *);
void *aml_area_mmap(struct aml_area *, void *, size_t);
int aml_area_available(struct aml_area *);
int aml_area_binding(struct aml_area *, struct aml_binding *);
int aml_area_binding(struct aml_area *, struct aml_binding **);
/*******************************************************************************
* DMA Engines:
......
......@@ -55,7 +55,7 @@ int aml_area_available(struct aml_area *area)
return area->ops->available(area->data);
}
int aml_area_binding(struct aml_area *area, struct aml_binding *binding)
int aml_area_binding(struct aml_area *area, struct aml_binding **binding)
{
assert(area != NULL);
return area->ops->binding(area->data, binding);
......
......@@ -28,7 +28,7 @@ int aml_area_linux_available(struct aml_area_data *a)
return 1;
}
int aml_area_linux_binding(struct aml_area_data *a, struct aml_binding *b)
int aml_area_linux_binding(struct aml_area_data *a, struct aml_binding **b)
{
assert(a != NULL);
struct aml_area_linux *area = (struct aml_area_linux *)a;
......
......@@ -10,7 +10,7 @@
/* common to both methods */
int aml_area_linux_mbind_generic_binding(struct aml_area_linux_mbind_data *data,
struct aml_binding *b)
struct aml_binding **b)
{
assert(data != NULL);
/* not exactly proper, we should inspect the nodemask to find the real
......@@ -20,12 +20,12 @@ int aml_area_linux_mbind_generic_binding(struct aml_area_linux_mbind_data *data,
{
for(int i = 0; i < AML_MAX_NUMA_NODES; i++)
if(AML_NODEMASK_ISSET(data->nodemask, i))
return aml_binding_init(b, AML_BINDING_TYPE_SINGLE,i);
return aml_binding_create(b, AML_BINDING_TYPE_SINGLE,i);
}
else if(data->policy == MPOL_INTERLEAVE)
{
return aml_binding_init(b, AML_BINDING_TYPE_INTERLEAVE,
data->nodemask);
return aml_binding_create(b, AML_BINDING_TYPE_INTERLEAVE,
data->nodemask);
}
return 0;
}
......
......@@ -26,11 +26,11 @@ int aml_area_posix_available(struct aml_area_data *data)
/* same thing here, it makes no sense to ask for this area to provide its
* binding scheme, as no-one should migrate to this area.
*/
int aml_area_posix_binding(struct aml_area_data *data, struct aml_binding *b)
int aml_area_posix_binding(struct aml_area_data *data, struct aml_binding **b)
{
assert(data != NULL);
/* numa node 0 should always be available */
return aml_binding_init(b, AML_BINDING_TYPE_SINGLE, 0);
return aml_binding_create(b, AML_BINDING_TYPE_SINGLE, 0);
}
/*******************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment