Add missing null checks after allocations.
Bug: http://b/20317729
Change-Id: I62bb761d48ee59a1f4ddd0cdd0632432305ca2ca
diff --git a/usb_linux_client.cpp b/usb_linux_client.cpp
index 6d21104..18289e2 100644
--- a/usb_linux_client.cpp
+++ b/usb_linux_client.cpp
@@ -241,6 +241,8 @@
static void usb_adb_init()
{
usb_handle* h = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
+ if (h == nullptr) fatal("couldn't allocate usb_handle");
+
h->write = usb_adb_write;
h->read = usb_adb_read;
h->kick = usb_adb_kick;
@@ -468,6 +470,8 @@
D("[ usb_init - using FunctionFS ]\n");
usb_handle* h = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
+ if (h == nullptr) fatal("couldn't allocate usb_handle");
+
h->write = usb_ffs_write;
h->read = usb_ffs_read;
h->kick = usb_ffs_kick;