Merge "Check validity of partition for getvar:partition-type" am: 9810709d91
am: de809e0122

Change-Id: Ia7124a423e9caab4481230ce3a093c75d6c105ff
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp
index c8756ae..cbd2856 100644
--- a/fastboot/device/variables.cpp
+++ b/fastboot/device/variables.cpp
@@ -308,7 +308,14 @@
         *message = "Missing argument";
         return false;
     }
+
     std::string partition_name = args[0];
+    if (!FindPhysicalPartition(partition_name) &&
+        !LogicalPartitionExists(partition_name, device->GetCurrentSlot())) {
+        *message = "Invalid partition";
+        return false;
+    }
+
     auto fastboot_hal = device->fastboot_hal();
     if (!fastboot_hal) {
         *message = "Fastboot HAL not found";