Canon issued a product advisory covering a potential focusing problem with the 40mm f/2.8 STM pancake lens.
In short, if you put pressure on the front of the lens, it may stop auto focusing. If this happens, you can fix the problem by detaching, then reattaching the lens. We should see a firmware update to correct this soon.