Devm

1

Why Linux Driver probe Failure Paths Are More Bug-Prone Than Successful probe

7 minute

Driver debugging often focuses on the successful probe path: acquire resources, map registers, request interrupt, initialize hardware, register user-space interface, then print “probe ok”.

Field bugs often hide on another path:

  • probe fails halfway and does not roll back cleanly
  • probe returns an error while IRQ or workqueue is still active
  • user space keeps an fd after remove
  • runtime suspend is powering down while the error path releases resources
  • DMA buffer is freed while the device is still writing
  • devm_ is used, but object lifetime is not what the driver expected

The hard part is not initializing hardware once. The hard part is: if any step fails, the device is removed, the module unloads, the system suspends, or user space still holds an fd, the driver must stop everything it has already started in the right order.

Read More