> > + sbridge_dev->n_devs = table->n_devs_per_imc;
> >
> > Do you need this? I thought that kzalloc_flex() filled in the __counted_by
> > field of the structure for you.
> kzalloc_flex is just a macro over kzalloc(struct_size()). It does not
> do automatic __counted_by, which makes no sense.
It is a fancy macro. But may be complier version dependent whether the count is
filled in.
See include/linux/slab.h where kzalloc_flex() uses __alloc_flex() which looks
like this:
#define __alloc_flex(KMALLOC, GFP, TYPE, FAM, COUNT) \
({ \
const size_t __count = (COUNT); \
const size_t __obj_size = struct_size_t(TYPE, FAM, __count); \
TYPE *__obj_ptr = KMALLOC(__obj_size, GFP); \
if (__obj_ptr) \
__set_flex_counter(__obj_ptr->FAM, __count); \
__obj_ptr; \
})
See the __set_flex_counter() ... looks like it is trying to set the counted_by
field.
-Tony