From patchwork Thu Dec 23 21:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 1572854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=B/VZA8Sg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4JKjlc6xjFz9tjv for ; Fri, 24 Dec 2021 08:20:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350332AbhLWVU2 (ORCPT ); Thu, 23 Dec 2021 16:20:28 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:28360 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233222AbhLWVU1 (ORCPT ); Thu, 23 Dec 2021 16:20:27 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BNL7M4M003628; Thu, 23 Dec 2021 21:20:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=KD53UhWatF1qnz6crGsdYk1yckbhPshN2q/ybLlYhg4=; b=B/VZA8SgfldkoetuTJCnNb6i6JUVDQGCO4kwbwCcKyk0nXjkehME6Z83rm7uGHFYykMv T+wUYnvE8/8bVAcJwXBMNAu3a5OkPjQGhz2ycP4qoKpsdEmaMmK9f5bHL5EpbJO8H2ki d6bEQ/H1czVq/063j/JLXLQjBCJuYRFQd2irM5dZFnDfL4LuNaWcbVFwnVlNbjXRVtMy po/O3i+NbFvkAypSyyZEaKxZudsLYesnlWOuvuncPuduWgwalcB5hB0M43AbiIihPRBb mjk1ABNqmtYYtCKL1Q1ga2d8m+xaooTv3TdVf750xO4KEH3VztA3G6I79aocN7tCLZco Dg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d4wr333e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:20:21 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1BNLBD4p014782; Thu, 23 Dec 2021 21:20:21 GMT Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d4wr333dj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:20:20 +0000 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BNLKF8I004008; Thu, 23 Dec 2021 21:20:19 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma03wdc.us.ibm.com with ESMTP id 3d179bg2q6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:20:19 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BNLJaWo26608102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Dec 2021 21:19:36 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 893E2BE05D; Thu, 23 Dec 2021 21:19:36 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E145DBE058; Thu, 23 Dec 2021 21:19:34 +0000 (GMT) Received: from farosas.linux.ibm.com.com (unknown [9.163.19.83]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 23 Dec 2021 21:19:34 +0000 (GMT) From: Fabiano Rosas To: kvm-ppc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, paulus@ozlabs.org, mpe@ellerman.id.au, npiggin@gmail.com Subject: [PATCH 1/3] KVM: PPC: Book3S HV: Check return value of kvmppc_radix_init Date: Thu, 23 Dec 2021 18:19:29 -0300 Message-Id: <20211223211931.3560887-2-farosas@linux.ibm.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223211931.3560887-1-farosas@linux.ibm.com> References: <20211223211931.3560887-1-farosas@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wDrn8XUly1dnT9URGmF9ejwFqEfMs5Lu X-Proofpoint-ORIG-GUID: xiNTTQLxLKXFWyroQNOyfq5w2UbQ1Wdc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-23_04,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=833 adultscore=0 impostorscore=0 clxscore=1015 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112230106 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org The return of the function is being shadowed by the call to kvmppc_uvmem_init. Fixes: ca9f4942670c ("KVM: PPC: Book3S HV: Support for running secure guests") Signed-off-by: Fabiano Rosas Reviewed-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 7b74fc0a986b..9f4765951733 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -6098,8 +6098,11 @@ static int kvmppc_book3s_init_hv(void) if (r) return r; - if (kvmppc_radix_possible()) + if (kvmppc_radix_possible()) { r = kvmppc_radix_init(); + if (r) + return r; + } r = kvmppc_uvmem_init(); if (r < 0) From patchwork Thu Dec 23 21:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 1572856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=VT4gGb3J; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4JKjln5fMnz9tjv for ; Fri, 24 Dec 2021 08:20:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350333AbhLWVUg (ORCPT ); Thu, 23 Dec 2021 16:20:36 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33110 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233222AbhLWVUf (ORCPT ); Thu, 23 Dec 2021 16:20:35 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BNLBjFs030317; Thu, 23 Dec 2021 21:20:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=t14t2vj/S6GC1hZeq8psc24jMksUbqcWz8p32ljojM0=; b=VT4gGb3J2iYR2G3pq6F95YJ0BBo6YgY3TaitAm4d+40JYN5qmjeUxuD1eGyeyJow98I4 J0g7HStPo028ZA7Fb4wQnpinEUbyt87Fw//aiQSi0uPM8NDfpiG3qLrx5IF/IUGFPT1n yPo3kbY6Uyd8WieUH/OuyVE5CJktzJM6QZFI51UTTBSip2TfUpi5T9crIN0qiiievxzq 41yNzNSy8JWMkQCXgXcyCbsybbmHQNmHB1ouz9ks2UObu4qn+q6oOajhIgMq25uussPK PfWKxClX84PkQTW39Nj495r9Eo1sHCSAli6yRstNy6SFC3IoZ/fRwTTEQQoebfxtoDJN ow== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3d50te83yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:20:27 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1BNLCOlL031386; Thu, 23 Dec 2021 21:20:27 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3d50te83y5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:20:27 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BNLKIsS016542; Thu, 23 Dec 2021 21:20:26 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 3d179cqdtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:20:26 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BNLJcf728049728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Dec 2021 21:19:38 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AEA6DBE063; Thu, 23 Dec 2021 21:19:38 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECA84BE05D; Thu, 23 Dec 2021 21:19:36 +0000 (GMT) Received: from farosas.linux.ibm.com.com (unknown [9.163.19.83]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 23 Dec 2021 21:19:36 +0000 (GMT) From: Fabiano Rosas To: kvm-ppc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, paulus@ozlabs.org, mpe@ellerman.id.au, npiggin@gmail.com Subject: [PATCH 2/3] KVM: PPC: Book3S HV: Delay setting of kvm ops Date: Thu, 23 Dec 2021 18:19:30 -0300 Message-Id: <20211223211931.3560887-3-farosas@linux.ibm.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223211931.3560887-1-farosas@linux.ibm.com> References: <20211223211931.3560887-1-farosas@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: JFOmQZ0HQsOqR0YOVZBiWcB3citxsPz0 X-Proofpoint-GUID: _phdkWjETO7giu6CqoiNPz03Hx1fUGsU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-23_04,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=853 malwarescore=0 priorityscore=1501 mlxscore=0 phishscore=0 impostorscore=0 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112230106 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org 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 --- arch/powerpc/kvm/book3s_hv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 9f4765951733..53400932f5d8 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -6087,9 +6087,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(); @@ -6105,10 +6102,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) From patchwork Thu Dec 23 21:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 1572852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=PdNfjxGh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4JKjky25mwz9tjv for ; Fri, 24 Dec 2021 08:19:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350331AbhLWVTw (ORCPT ); Thu, 23 Dec 2021 16:19:52 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57056 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233222AbhLWVTt (ORCPT ); Thu, 23 Dec 2021 16:19:49 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BNL5qvt028886; Thu, 23 Dec 2021 21:19:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=himf4nqViNdME7f5Fn0dx0Uj2a2JkriHSzZZyh/AASU=; b=PdNfjxGh0bcPiRNu+TNbegvN61ay+ge9dapN2D2aIWN1Qaqxhmn0vQM5f2lr/LAMZoa+ 6IC1UdSI6ITEjjKUDdK37pA0rRxouulGSGz0xANkXdq95eezWjCxXLBdvZXXi6Pzfz7V EaSFOsoDYkOci4V1VLA5ffGYrlXxZS6boKVMX2bAxdEVHc245JNrFe6MCySz9k69Gt5M q4218+Uq4yp6qztcPyhLWpeXFhxPeQivc/vYOxa/OJOARjAXHYpAimrN+t0ZlkzvoSlf t4kTcdHMcUxDSWLA6+1gSkINlPR3N2xp/l2Tnm952wAKp54wfNVAIG0+RjExnrPGBiQn 7A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d4u3p6gqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:19:44 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1BNLJhRT032011; Thu, 23 Dec 2021 21:19:43 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d4u3p6gq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:19:43 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BNLHOja004596; Thu, 23 Dec 2021 21:19:42 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01dal.us.ibm.com with ESMTP id 3d179cybyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Dec 2021 21:19:42 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BNLJeM111272932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Dec 2021 21:19:40 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0992BE05D; Thu, 23 Dec 2021 21:19:40 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DAE0BE058; Thu, 23 Dec 2021 21:19:39 +0000 (GMT) Received: from farosas.linux.ibm.com.com (unknown [9.163.19.83]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 23 Dec 2021 21:19:38 +0000 (GMT) From: Fabiano Rosas To: kvm-ppc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, paulus@ozlabs.org, mpe@ellerman.id.au, npiggin@gmail.com Subject: [PATCH 3/3] KVM: PPC: Book3S HV: Free allocated memory if module init fails Date: Thu, 23 Dec 2021 18:19:31 -0300 Message-Id: <20211223211931.3560887-4-farosas@linux.ibm.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223211931.3560887-1-farosas@linux.ibm.com> References: <20211223211931.3560887-1-farosas@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7ohbHWmd_bUce-D2sURNTqkrIYljxiyX X-Proofpoint-GUID: buAxf0rA5X5yAh6f2Wtx-BB-7BA3usD6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-23_04,2021-12-22_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 priorityscore=1501 mlxlogscore=855 adultscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112230106 Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org The module's exit function is not called when the init fails, we need to do cleanup before returning. Signed-off-by: Fabiano Rosas Reviewed-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 53400932f5d8..2d79298e7ca4 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -6065,7 +6065,7 @@ static int kvmppc_book3s_init_hv(void) r = kvm_init_subcore_bitmap(); if (r) - return r; + goto err; /* * We need a way of accessing the XICS interrupt controller, @@ -6080,7 +6080,8 @@ static int kvmppc_book3s_init_hv(void) np = of_find_compatible_node(NULL, NULL, "ibm,opal-intc"); if (!np) { pr_err("KVM-HV: Cannot determine method for accessing XICS\n"); - return -ENODEV; + r = -ENODEV; + goto err; } /* presence of intc confirmed - node can be dropped again */ of_node_put(np); @@ -6093,12 +6094,12 @@ static int kvmppc_book3s_init_hv(void) r = kvmppc_mmu_hv_init(); if (r) - return r; + goto err; if (kvmppc_radix_possible()) { r = kvmppc_radix_init(); if (r) - return r; + goto err; } r = kvmppc_uvmem_init(); @@ -6111,6 +6112,12 @@ static int kvmppc_book3s_init_hv(void) kvmppc_hv_ops = &kvm_ops_hv; return 0; + +err: + kvmhv_nested_exit(); + kvmppc_radix_exit(); + + return r; } static void kvmppc_book3s_exit_hv(void)