>
> > + for (j = 0; j < 4; j++) {
> > + struct cpu_core *core;
> > +
> > + core = CONTAINER_OF(hmap_first_with_hash(&all_cpu_cores,
> > +
> hash_int(core_id++, 0)),
> > + struct cpu_core, hmap_node);
> > + core->available = (bin >> j) & 0x1;
> This can result in NULL pointer deref if cores are not multiple of 4.
> I am not sure how "(bin >> j) & 0x1" works, easier way would be to
> test for bits set in bin and then lookup the core.
>
>
After discussion offline, the "(bin >> j) & 0x1" logic is fine.
To fix the deref of NULL pointer when the number of cores not multiple of 4,
the following change is made:
diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c
index c4a9727..26ab3cf 100644
--- a/lib/ovs-numa.c
+++ b/lib/ovs-numa.c
@@ -328,7 +328,7 @@ ovs_numa_unpin_core(int core_id)
/* Reads the cpu mask configuration from 'cmask' and sets the
* 'available' of corresponding cores. For unspecified cores,
- * sets 'available' to true. */
+ * sets 'available' to false. */
void
ovs_numa_set_cpu_mask(const char *cmask)
{
@@ -370,11 +370,11 @@ ovs_numa_set_cpu_mask(const char *cmask)
hash_int(core_id++,
0)),
struct cpu_core, hmap_node);
core->available = (bin >> j) & 0x1;
- }
- if (core_id >= hmap_count(&all_cpu_cores)) {
- return;
- }
+ if (core_id >= hmap_count(&all_cpu_cores)) {
+ return;
+ }
+ }
}
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev