Please point out the mistake in the logic of my code(if any). It is a function attempting to insert an element at the beginning of a Doubly Linked List in C language.
struct DLL *insertAthead(struct DLL *head, int newData)
{
    struct DLL *p = (struct DLL *)malloc(sizeof(struct DLL *));
    p->prev = NULL;
    p->next = head;
    head->prev = p;
    p->data = newData;
    head = p;
    return head;
}
 
    