SEGSIEV error while submission

I have written the code(function ) for the following problem but i keep getting segmentation fault. Please help find out where i am going wrong.
problem : https://practice.geeksforgeeks.org/problems/remove-duplicate-element-from-sorted-linked-list/1

My solution:

Node *removeDuplicates(Node *a)
{ if(a==NULL|| a->next == NULL) return a;
Node * A =a;
while(A->next!= NULL){
if(A->data == (A->next)->data){
if((A->next)->next == NULL){
A->next = NULL;
}
else{
A->next = (A->next)->next;
}
}
A= A->next;
}
return a;
}