From patchwork Tue Jun 10 07:32:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyi Zhou X-Patchwork-Id: 357760 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6959A1400BB for ; Tue, 10 Jun 2014 17:33:25 +1000 (EST) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 4A3E51A0835 for ; Tue, 10 Jun 2014 17:33:25 +1000 (EST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pb0-x22b.google.com (mail-pb0-x22b.google.com [IPv6:2607:f8b0:400e:c01::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 5AA0F1A00D3 for ; Tue, 10 Jun 2014 17:32:47 +1000 (EST) Received: by mail-pb0-f43.google.com with SMTP id up15so5934681pbc.2 for ; Tue, 10 Jun 2014 00:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=3oxTwIG3MPqWiRYH9LHSZbnRk4U99KB+W3Hnu2+kb3o=; b=QiXyDfFNjOkUt2grOqZywI86KS6RZnFXkLQIeBcNwbtVt4eWUslOtT9rlz9FomAm8K TkdTpZ4a5dYy1dXAl1jvkRLFDVrzWPuRJJqMsSe+V8vVnUJWN6tjDPtjrJrO4XalXC8T jJE2qhp38Vp2RgIbK3yWL6QdTFaPWrDykzYTt9wrSia764HLpvdf7eXgfRT7kgLQmLyl ChwqgxorlWD6qWD29M9h8GUij/sC6U0YjWbf+CLzXhmKUV2iHQTlPXIeLoK65WdlwYr/ qBAEe4XFiPI5pGpMBvnlYPUATlaBUmpl9UKIJ1ks8POBe3ju2VgzgZXh6QegCOxqtml4 SOug== X-Received: by 10.68.196.168 with SMTP id in8mr9971617pbc.132.1402385564689; Tue, 10 Jun 2014 00:32:44 -0700 (PDT) Received: from localhost.localdomain ([159.226.43.61]) by mx.google.com with ESMTPSA id ek2sm67827743pbd.30.2014.06.10.00.32.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Jun 2014 00:32:43 -0700 (PDT) From: Zhouyi Zhou To: , , , , , , , , Subject: [PATCH 1/1] powerpc/iommu: Handling null return of kzalloc_node Date: Tue, 10 Jun 2014 15:32:10 +0800 Message-Id: <1402385530-23091-1-git-send-email-zhouzhouyi@gmail.com> X-Mailer: git-send-email 1.7.10.4 Cc: Zhouyi Zhou , Zhouyi Zhou X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" NULL return of kzalloc_node should be handled Signed-off-by: Zhouyi Zhou --- arch/powerpc/platforms/pseries/iommu.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 33b552f..593cd3d 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -613,7 +613,11 @@ static void pci_dma_bus_setup_pSeries(struct pci_bus *bus) tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, pci->phb->node); - + if (!tbl) { + pr_debug(" out of memory, can't create iommu_table !\n"); + return; + } + iommu_table_setparms(pci->phb, dn, tbl); pci->iommu_table = iommu_init_table(tbl, pci->phb->node); iommu_register_group(tbl, pci_domain_nr(bus), 0); @@ -659,6 +663,10 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus) if (!ppci->iommu_table) { tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, ppci->phb->node); + if (!tbl) { + pr_debug(" out of memory, can't create iommu_table !\n"); + return; + } iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window); ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node); iommu_register_group(tbl, pci_domain_nr(bus), 0); @@ -686,6 +694,11 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev) pr_debug(" --> first child, no bridge. Allocating iommu table.\n"); tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, phb->node); + if (!tbl) { + pr_debug(" out of memory, can't create iommu_table !\n"); + return; + } + iommu_table_setparms(phb, dn, tbl); PCI_DN(dn)->iommu_table = iommu_init_table(tbl, phb->node); iommu_register_group(tbl, pci_domain_nr(phb->bus), 0); @@ -1102,6 +1116,10 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev) if (!pci->iommu_table) { tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, pci->phb->node); + if (!tbl) { + pr_debug(" out of memory, can't create iommu_table !\n"); + return; + } iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window); pci->iommu_table = iommu_init_table(tbl, pci->phb->node); iommu_register_group(tbl, pci_domain_nr(pci->phb->bus), 0);