]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: PPC: Book3S HV: Delay setting of kvm ops
authorFabiano Rosas <farosas@linux.ibm.com>
Tue, 25 Jan 2022 15:57:33 +0000 (12:57 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Feb 2022 05:50:44 +0000 (16:50 +1100)
Delay the setting of kvm_hv_ops until after all init code has
completed. This avoids leaving the ops still accessible if the init
fails.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220125155735.1018683-3-farosas@linux.ibm.com
arch/powerpc/kvm/book3s_hv.c

index 98ec92cf837bd935d69e8985791fbc3a46205da8..ec56970175e279a010188586e76128a505895dbf 100644 (file)
@@ -6119,9 +6119,6 @@ static int kvmppc_book3s_init_hv(void)
        }
 #endif
 
-       kvm_ops_hv.owner = THIS_MODULE;
-       kvmppc_hv_ops = &kvm_ops_hv;
-
        init_default_hcalls();
 
        init_vcore_lists();
@@ -6137,10 +6134,15 @@ static int kvmppc_book3s_init_hv(void)
        }
 
        r = kvmppc_uvmem_init();
-       if (r < 0)
+       if (r < 0) {
                pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r);
+               return r;
+       }
 
-       return r;
+       kvm_ops_hv.owner = THIS_MODULE;
+       kvmppc_hv_ops = &kvm_ops_hv;
+
+       return 0;
 }
 
 static void kvmppc_book3s_exit_hv(void)