You do have memory leak issue. In an interview, this could make you fail. However, it is easy to fix: just create ListNode dummy; and use dummy.next = head; ListDode* prev = &dummy;
On the other hand, the **p technique that leaper showed is a more advanced way which Mr. Linuz used in Linux kernel, and we all should learn.