Assign the intersection combination of two linked lists to linked list a

typedef struct node
{
    int data;
    struct node *next;
} LNode, *LinkList;

LinkList Unions(LinkList la, LinkList lb)
{
    LNode *p, *q, *w, *u;
    p = la->next;
    q = lb->next;
    w = la;
    while (p && q)
    {
        if (p->data == q->data)
        {
            w->next = p;
            w = w->next;
            p = p->next;
            u = q;
            q = q->next;
            free(u);
        }
        else if (p->data < q->data)
        {
            u = p;
            p = p->next;
            free(u);
        }
        else
        {
            u = q;
            q = q->next;
            free(q);
        }
    }
    if (q)
    {
        p = q;
    }
    while (q)
    {
        u = q;
        q = q->next;
        free(u);
    }
    w->next = NULL;
    free(lb);
    return la;
}

Read More: