From patchwork Tue Jun 23 08:37:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamalesh Babulal X-Patchwork-Id: 487538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 2C7E7140082 for ; Tue, 23 Jun 2015 18:39:24 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 128D01A0FBD for ; Tue, 23 Jun 2015 18:39:24 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 1EB221A0F78 for ; Tue, 23 Jun 2015 18:38:51 +1000 (AEST) Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 23 Jun 2015 18:38:50 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 23 Jun 2015 18:38:48 +1000 X-Helo: d23dlp02.au.ibm.com X-MailFrom: kamalesh@linux.vnet.ibm.com X-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id B63B62BB0054 for ; Tue, 23 Jun 2015 18:38:47 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t5N8ccWU59179254 for ; Tue, 23 Jun 2015 18:38:46 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t5N8cF9q030607 for ; Tue, 23 Jun 2015 18:38:15 +1000 Received: from Kepler.in.ibm.com ([9.124.158.158]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t5N8btP2029336; Tue, 23 Jun 2015 18:38:14 +1000 From: Kamalesh Babulal To: skiboot@lists.ozlabs.org Date: Tue, 23 Jun 2015 14:07:38 +0530 Message-Id: <3ded3d5442aea11028d1eddfb21f2eee50f27e14.1435048542.git.kamalesh@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: References: In-Reply-To: References: X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15062308-0013-0000-0000-00000173B3A5 Subject: [Skiboot] [PATCH 8/8] Introduce memory allocation return value check X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" In pci_std_swizzle_irq_map(), check if the memory allocation of interrupt-mask returns a valid pointer before using it. Fixes Coverity defect#97854. Signed-off-by: Kamalesh Babulal --- core/pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/pci.c b/core/pci.c index fe23d6c..ae71814 100644 --- a/core/pci.c +++ b/core/pci.c @@ -1087,6 +1087,10 @@ void pci_std_swizzle_irq_map(struct dt_node *np, } map_size = esize * edevcount * 4 * sizeof(uint32_t); map = p = zalloc(map_size); + if (!map) { + prlog(PR_DEBUG, "Failed to allocate interrupt-map-mask !\n"); + goto fail; + } for (dev = 0; dev < edevcount; dev++) { for (irq = 0; irq < 4; irq++) { @@ -1111,7 +1115,9 @@ void pci_std_swizzle_irq_map(struct dt_node *np, } dt_add_property(np, "interrupt-map", map, map_size); - free(map); +fail: + if (map) + free(map); } static void pci_add_slot_properties(struct phb *phb, struct pci_slot_info *info,