This is the basic idea of the good faith exception to the exclusionary rule. The exclusionary rule was supposed to deter police misconduct (e.g., searching a house without a warrant, thereby violating the Fourth Amendment) by preventing them from using evidence they never should have had. But the deterrence rationale doesn't hold up that well when the police reasonably (and that's key) believed that they were acting lawfully.