trusty: storageproxyd: Fix rebase of UFS support

The UFS support got rebased on top of the RPMB socket support
improperly. As a result, RPMB socket support was broken due to an
unconditional rmpb_fd = rc which would set the rpmb_fd to be connect()'s
error code in the case of an RPMB socket.

Bug: 146903427
Test: Boot Trusty+Android with the rpmb_dev mock, check for liveness
Change-Id: Ib1220dc49392f1a10369eed7716e44680bd83a66
diff --git a/trusty/storage/proxy/rpmb.c b/trusty/storage/proxy/rpmb.c
index 03b1099..7dfd0d0 100644
--- a/trusty/storage/proxy/rpmb.c
+++ b/trusty/storage/proxy/rpmb.c
@@ -361,6 +361,15 @@
             return rc;
         }
         rpmb_fd = rc;
+
+        /* For UFS, it is prudent to check we have a sg device by calling an ioctl */
+        if (dev_type == UFS_RPMB) {
+            if ((ioctl(rpmb_fd, SG_GET_VERSION_NUM, &sg_version_num) < 0) ||
+                (sg_version_num < RPMB_MIN_SG_VERSION_NUM)) {
+                ALOGE("%s is not a sg device, or old sg driver\n", rpmb_devname);
+                return -1;
+            }
+        }
     } else {
         struct sockaddr_un unaddr;
         struct sockaddr *addr = (struct sockaddr *)&unaddr;
@@ -382,15 +391,6 @@
         }
     }
 
-    /* For UFS, it is prudent to check we hava a sg device by calling an ioctl */
-    if (dev_type == UFS_RPMB) {
-        if ((ioctl(rc, SG_GET_VERSION_NUM, &sg_version_num) < 0) ||
-            (sg_version_num < RPMB_MIN_SG_VERSION_NUM)) {
-            ALOGE("%s is not a sg device, or old sg driver\n", rpmb_devname);
-            return -1;
-        }
-    }
-    rpmb_fd = rc;
     return 0;
 }