Null check for malloc allocation

Add NULL check after memory allocation

Change-Id: Id5dc6d2e5b13aa7979067ab22963df96b32e49c5
CRs-fixed: 561182
This commit is contained in:
Tushar Janefalkar 2013-10-16 16:39:01 -07:00
parent b1e5bb90ac
commit efdc209caf

View file

@ -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;