exynos9610: USB: HIDL: check the status of
authorBadhri Jagan Sridharan <Badhri@google.com>
Wed, 29 Mar 2017 18:45:18 +0000 (11:45 -0700)
committerJan Altensen <info@stricted.net>
Sun, 1 Nov 2020 02:06:26 +0000 (03:06 +0100)
 registerAsService

registerAsService call could fail. Hence check the return value.

Bug: 36704362
Change-Id: I46dcd74dbee6aba72cf344f10854e5d4b1b6de18

hidl/usb/service.cpp

index 2a53c3d1ff8f9240390cd0dbda6adf5f964665a2..fbc099eed612beacec6a77bedd41b9e3320acb44 100644 (file)
@@ -27,12 +27,24 @@ using android::hardware::joinRpcThreadpool;
 using android::hardware::usb::V1_0::IUsb;
 using android::hardware::usb::V1_0::implementation::Usb;
 
+using android::status_t;
+using android::OK;
+
 int main() {
     android::sp<IUsb> service = new Usb();
 
     configureRpcThreadpool(1, true /*callerWillJoin*/);
-    service->registerAsService();
+    status_t status = service->registerAsService();
+
+    if (status != OK) {
+        ALOGE("Cannot register USB HAL service");
+        return 1;
+    }
 
     ALOGI("USB HAL Ready.");
     joinRpcThreadpool();
+    // Under noraml cases, execution will not reach this line.
+    ALOGI("USB HAL failed to join thread pool.");
+    return 1;
+
 }