hash_key8_ext, hash_key16_ext and hash_key32_ext tables allocate cache
entries to support table overload cases. The crash can occur when cache
entry is free after use.
The problem is with computing the index of the free cache entry.
Signed-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>
Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
memset(bucket, 0,
sizeof(struct rte_bucket_4_16));
- bucket_index = (bucket -
- ((struct rte_bucket_4_16 *)
- f->memory)) - f->n_buckets;
+ bucket_index = (((uint8_t *)bucket -
+ (uint8_t *)f->memory)/f->bucket_size) - f->n_buckets;
f->stack[f->stack_pos++] = bucket_index;
}
memset(bucket, 0,
sizeof(struct rte_bucket_4_32));
- bucket_index = (bucket -
- ((struct rte_bucket_4_32 *)
- f->memory)) - f->n_buckets;
+ bucket_index = (((uint8_t *)bucket -
+ (uint8_t *)f->memory)/f->bucket_size) - f->n_buckets;
f->stack[f->stack_pos++] = bucket_index;
}
memset(bucket, 0,
sizeof(struct rte_bucket_4_8));
- bucket_index = (bucket -
- ((struct rte_bucket_4_8 *)
- f->memory)) - f->n_buckets;
+ bucket_index = (((uint8_t *)bucket -
+ (uint8_t *)f->memory)/f->bucket_size) - f->n_buckets;
f->stack[f->stack_pos++] = bucket_index;
}