力扣题,删除链表中的特定节点,请问这样写有什么问题吗?

```c
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteNode(struct ListNode* head, int val) {
struct ListNode*p,*p0,*q;
p=p0=head;
if(p->val==val)
{
head=head->next;
return head;
}
else
{
p=p->next;
}
while(p!=NULL)
{
if(p->val==val)
{
q=p;
p=p->next;
p0->next=p;
free(q);
}
else
{
p0=p;
p=p->next;
}
}
return head;
}
```