Null check for malloc allocation
Add NULL check after memory allocation Change-Id: Id5dc6d2e5b13aa7979067ab22963df96b32e49c5 CRs-fixed: 561182
This commit is contained in:
parent
b1e5bb90ac
commit
efdc209caf
1 changed files with 4 additions and 0 deletions
|
@ -42,6 +42,10 @@ static int open_gps(const struct hw_module_t* module, char const* name,
|
|||
struct hw_device_t** device)
|
||||
{
|
||||
struct gps_device_t *dev = (struct gps_device_t *) malloc(sizeof(struct gps_device_t));
|
||||
|
||||
if(dev == NULL)
|
||||
return -1;
|
||||
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
dev->common.tag = HARDWARE_DEVICE_TAG;
|
||||
|
|
Loading…
Reference in a new issue