hal: add checks for possible NULL dereferences in hal

Add checks for possible NULL dereferences in hal.

Change-Id: I56c9238eb7b686628c62c02e5ff635faabb1bd81
2 files changed