Fix compilation errors
Fix NULL pointer comparaison with integer
Ensure that tofree is set to NULL when it needs
Fix size calculation for ioctls whitelist
Rework locking of ioctls whitelist