>>109390469
The risk comes from container_of, where it's possible to give it the wrong intrusive member element.
struct test {
int data;
// This struct could be part of 2 lists simentaneously
struct list_head link_1;
struct list_head link_2;
};
int main()
{
struct list_head head;
list_init(&head);
struct test a = ...;
list_add(&a.link_1, &head);
struct test *iter;
// Macro expands to a for loop that walks the list
list_for_each(iter, &head, link_2) { // Should be link_1
// Iter incorrectly points to 16 bytes BEFORE the element
}
}
You can do some type system stuff to make it fail on giving the wrong type entirely, but this is just a decently uncommon case where you have the chance to fuck it up.