During my tests, I have found that it is possible to use pointer after free(). I have the following code:
typedef struct{
int module_id;
int adc_id;
When you call free(phead), the memory phead points to is being freed, but the value of phead stays untouched, making the phead a dangling pointer. Accessing the memory that has already been freed produces undefined behavior.
It is a good practice to assign NULL to the pointer once you free the memory it points to:
free(phead);
phead = NULL;