Merge "Null check for malloc allocation"
This commit is contained in:
commit
1f94c20487
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