Police freed about 500 men and boys from an Islamic school in northern Nigeria on Wednesday where some had been chained to walls, molested and beaten, police sources said.