Segmentation fault seems to be coming

#include
using namespace std;

class node
{
public:
node *prev;
int data;
node *next;

node(int d)
{
    prev=NULL; 
    data=d;
    next=NULL;
}

};

node *head=NULL;

void Display(node *p)
{
while(p!=NULL)
{
cout<data<<" ";
p=p->next;
}
cout<<endl;
}

void Create(int n)
{
int ele;
cin>>ele;
head=new node(ele);
node *last=head;

for(int i=0;i<n-1;i++)
{
    cin>>ele;
    node *t=new node(ele);
    t->prev=last;
    last->next=t;
    last=t;
}

}

void InsertionSort(int n)
{
node *p=head;
node *q=head->next;
for(int i=1;i<n;i++)
{
int x=q->data;
while(p->data>x && p!=NULL)
{
p->next->data=p->data;
p=p->prev;
}
if(q->prev!=head)
{
p=head;
}

    else
       p=q->prev;
    
    p->data=x;
    q=q->next;
    p=q->prev;
}

}

int main()
{
int n;
cin>>n;

Create(n);
InsertionSort(n);
Display(head);

}

hi @Mukul-Shane-1247687648773500,
sorry i was little busy
the code is not able to handle null pointer
you are doing int x=q->data;
but q becomes null just dry run for 2 nodes say 2 and 3
also its not retaining the node value (2) in this case