Use of cdev_alloc function

I'm creating a char device I'm initiating my cdev as below

dev=cdev_alloc(); //dev is struct cdev* declare with global scope
if(dev)
{
cdev_init(dev,&file_ops);//file_ops is struct file_operations declared with global scope
}

This code works well. But we know that cdev_alloc and cdev_init both can inititates struct cdev alone. So i thought to use cdev_init to initiate and i used below code

cdev_init(dev,&file_ops)

Now here comes my problem. When i'm initializing with cdev_init alone i'm unable to unload my module, as i'm cleaning up struct cdev with function `cdev_del()` which is throwing error. But what error i don't know

Please help. I'll provided further code if needed.