Insertion sort of a linked list
Code performs as expected.

Insertion sort has an expected O(n2) performance and OP's code has about 0.25*n2 compares per length n of a linked list.

By adding a counti to sortedInsert() and providing various length lists with random data to insertionSort(), the below graph was determined.

void sortedInsert(element_t** head_ref, element_t* new_node) {
  element_t* current;
  if (*head_ref == NULL || (*head_ref)-&gt;val &gt;= new_node-&gt;val) {

    counti++;  // *****

    new_node-&gt;next = *head_ref;
    *head_ref = new_node;
  } else {
    current = *head_ref;

    counti++;  // *****

    while (current-&gt;next != NULL &amp;&amp; current-&gt;next-&gt;val &lt; new_node-&gt;val) {

      counti++;  // *****

      current = current-&gt;next;
    }
    new_node-&gt;next = current-&gt;next;
    current-&gt;next = new_node;
  }
}




No functional implementation problem found.

Lots of review-able issues (format, lack of supporting code, etc.), but OP did not ask for that.