Fix HAL implementation to check for error cases
am: 5cf6c14950

Change-Id: I89cb2d05c679001172f19514f0f4ead8e72130eb