LegacySupport: fix compile error for some devices am: c40b6510cb am: 3940f54aec am: f13ef016c6
am: c7c43d2669

Change-Id: I1228603f6f639b962781e4aecb2b368929b8e628
diff --git a/transport/include/hidl/LegacySupport.h b/transport/include/hidl/LegacySupport.h
index 0f37ae0..7cb72a9 100644
--- a/transport/include/hidl/LegacySupport.h
+++ b/transport/include/hidl/LegacySupport.h
@@ -42,9 +42,10 @@
 
     LOG_FATAL_IF(service->isRemote(), "Implementation of %s/%s is remote!",
             Interface::descriptor, name.c_str());
-    LOG_FATAL_IF(ExpectInterface::castFrom(service) == nullptr,
-                 "Implementation of %s/%s is not a %s!", Interface::descriptor, name.c_str(),
-                 ExpectInterface::descriptor);
+
+    sp<ExpectInterface> expected = ExpectInterface::castFrom(service);
+    LOG_FATAL_IF(expected == nullptr, "Implementation of %s/%s is not a %s!", Interface::descriptor,
+                 name.c_str(), ExpectInterface::descriptor);
 
     status_t status = registerServiceCb(service, name);