Embedded linux, after loading the driver, running the program causes the system to crash


The write buffer memory of the device is only 100 bytes, but the application needs to write 4096 bytes. If the consideration is not thorough, it is likely to cross the boundary when writing the driver cache, causing the system to crash.


test.c (application, user)


demo1.c (driver, kernel)


★★★ If copy_from_user(info,buf, count ) is rewritten to copy_from_user(info,buf, size ), the system will crash.



After restarting the virtual machine:




★★★The system crashes, after restarting the virtual machine, the nodes established in the /dev directory are cleared, and the device number applied in the /proc/devices file is cleared


The device files created by yourself are usually deleted after restarting, and the node needs to be recreated


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325577322&siteId=291194637