Make sure linked and linked_conn can't get out of sync

In #21576 (moved), we encountered a situation where linked is true, but linked_conn is NULL.

This shouldn't happen, so we need to diagnose the error, and fix it.