sensor: check NULL if memory allocation is failed