diff mbox

[kernel] KVM: PPC: Check kzalloc() return

Message ID 20170327031927.18572-1-aik@ozlabs.ru (mailing list archive)
State Accepted
Delegated to: Paul Mackerras
Headers show

Commit Message

Alexey Kardashevskiy March 27, 2017, 3:19 a.m. UTC
This adds missing check for failed kzalloc().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

This is a followup change for:
[PATCH kernel v11 10/10] KVM: PPC: VFIO: Add in-kernel acceleration for VFIO

Please squash it. Thanks!
---
 arch/powerpc/kvm/book3s_64_vio.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

David Gibson March 27, 2017, 4:25 a.m. UTC | #1
On Mon, Mar 27, 2017 at 02:19:27PM +1100, Alexey Kardashevskiy wrote:
> This adds missing check for failed kzalloc().
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
> 
> This is a followup change for:
> [PATCH kernel v11 10/10] KVM: PPC: VFIO: Add in-kernel acceleration for VFIO
> 
> Please squash it. Thanks!
> ---
>  arch/powerpc/kvm/book3s_64_vio.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> index 22c67a47eaab..c3d8a88f1f4e 100644
> --- a/arch/powerpc/kvm/book3s_64_vio.c
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -212,6 +212,11 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
>  	}
>  
>  	stit = kzalloc(sizeof(*stit), GFP_KERNEL);
> +	if (!stit) {
> +		iommu_tce_table_put(tbl);
> +		return -ENOMEM;
> +	}
> +
>  	stit->tbl = tbl;
>  	kref_init(&stit->kref);
>
diff mbox

Patch

diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index 22c67a47eaab..c3d8a88f1f4e 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -212,6 +212,11 @@  extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
 	}
 
 	stit = kzalloc(sizeof(*stit), GFP_KERNEL);
+	if (!stit) {
+		iommu_tce_table_put(tbl);
+		return -ENOMEM;
+	}
+
 	stit->tbl = tbl;
 	kref_init(&stit->kref);