Re: [PATCH v2 4/4] counter: Introduce the COUNTER_COMP_ARRAY component type

From: William Breathitt Gray
Date: Sat Sep 17 2022 - 08:30:41 EST


On Fri, Sep 16, 2022 at 08:39:28PM -0400, William Breathitt Gray wrote:
> +static int counter_array_attrs_create(struct device *const dev,
> + struct counter_attribute_group *const group,
> + const struct counter_comp *const comp,
> + const enum counter_scope scope,
> + void *const parent, const size_t id)
> +{
> + const struct counter_array *const array = comp->priv;
> + struct counter_comp ext = *comp;
> + struct counter_array *element;
> + size_t idx;
> + int err;
> +
> + /* Create an attribute for each array element */
> + for (idx = 0; idx < array->length; idx++) {
> + /* Set index for array element extension */
> + element = ext.priv;
> + element->idx = idx;

This is unintentionally overwriting the array length and thus skipping
the subsequent array elements. Instead, element should be a copy of the
array rather than a pointer to it. I'll fix this in a v3 release.

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature