Add missing null checks after allocations.

Bug: http://b/20317729
Change-Id: I62bb761d48ee59a1f4ddd0cdd0632432305ca2ca
diff --git a/services.cpp b/services.cpp
index ff13722..e6c84a4 100644
--- a/services.cpp
+++ b/services.cpp
@@ -689,6 +689,10 @@
         return create_device_tracker();
     } else if (!strncmp(name, "wait-for-", strlen("wait-for-"))) {
         auto sinfo = reinterpret_cast<state_info*>(malloc(sizeof(state_info)));
+        if (sinfo == nullptr) {
+            fprintf(stderr, "couldn't allocate state_info: %s", strerror(errno));
+            return NULL;
+        }
 
         if (serial)
             sinfo->serial = strdup(serial);