iommu/amd: Check for error states first in iommu_go_to_state()
authorJoerg Roedel <jroedel@suse.de>
Fri, 16 Jun 2017 14:09:57 +0000 (16:09 +0200)
committerJoerg Roedel <jroedel@suse.de>
Thu, 22 Jun 2017 10:54:20 +0000 (12:54 +0200)
Check if we are in an error state already before calling
into state_next().

Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu_init.c

index df9ec85..a6b81a0 100644 (file)
@@ -2467,14 +2467,14 @@ static int __init state_next(void)
 
 static int __init iommu_go_to_state(enum iommu_init_state state)
 {
-       int ret = 0;
+       int ret = -EINVAL;
 
        while (init_state != state) {
-               ret = state_next();
                if (init_state == IOMMU_NOT_FOUND         ||
                    init_state == IOMMU_INIT_ERROR        ||
                    init_state == IOMMU_CMDLINE_DISABLED)
                        break;
+               ret = state_next();
        }
 
        return ret;