Whenever I put any printk statements inside if-else block, it simply crashes the kernel in Linux.
A sample code is given below:
if (device-> Some condition) {
s = 0;
e = 0;
printk(KERN_INFO "I am 0 and 0 part \n");
printk(KERN_ALERT "KERN_INFO Successfully registered module \n");
} else {
s = 1;
e = 2;
printk(KERN_INFO "I am in 1 and 1 part \n");
}
The above code gets successfully compiled when I make it. But during insmod
kernel stops responding and ultimately crashes. On the contrary, if I comment out those printk
statements then I could easily do insmod
.
I would like to know the probable cause of this behavior and how could I remove such things.