Merge "hal: add checks for possible NULL dereferences in hal"