Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7108995ybi; Thu, 1 Aug 2019 03:20:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy25lVFbxD50OCGEyipSIOyL6jwbboQkqfQMiiAtYc17ohwHLiz7YPU5ZKC6mbwJBW9xmqf X-Received: by 2002:a62:cf07:: with SMTP id b7mr52768798pfg.217.1564654806725; Thu, 01 Aug 2019 03:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564654806; cv=none; d=google.com; s=arc-20160816; b=Ss6X4ikzmA5cP3xSdL64YiNHAY5+Vn1SPs5oJSJkbDXbkrSJuHgzbNBqwbfVtpc7FH Q9O1pIUqYhFEXiG+9HQCxrJIXbo5KewH7YEFK1kLeLQSVHC+OaZxuLrVQeprPQNzqq9t nnhD0oHnVRk7nxYabZtonDX9WqkSppnqy39MhA7WOnFiHHXRPjVmR+bMl9ao8mDKSqf4 r3XIrMRo8PLbMYn2BB0xDqGEMrKcB7iAPm55kTHEKAhb+CQ9/fBLDjk5iKTnc+t/NTUt lAYtcjaNHUDkBQdh8t24EpvjpVQ8y0THqP0BRwaH72LVKVtXISprtF63/HCotcVfhCAV trjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CIeP9aYiUDIKpCkE89mPP+kJ2AzAtVScTYO6LgNXbHY=; b=F2MY0unKJYIkKopSvaa4nzZInFo9tlr5ghAPzTG6QyGtGCTR+CLW69pZWev+8xUw6o hkyA8oEDxdXSlJw35ZrA74iLzpfpjSuuDu6F7UyRhQ5kFGOD2ql+eyBrXPWtty9Tk+Qz d1ddEs4z3auEJBOPv0bgasU/DB4MDQ6SwLHnvAI0GLec/c/t0BeDlfKDEQitRULgEmKJ adWa0BnXpubwsdJM5ATOgkT5MFO4qCz++RGILRS0p+6xWoPxxnm17hFJRlMsUeTCTw82 989fGEmLHXbUbsLSBTH8WrH4MuzluD9JMz046xvTSq2psK+X5DuAWvx3cgnhoeG25Q4l CjOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2si34640972pgm.242.2019.08.01.03.19.50; Thu, 01 Aug 2019 03:20:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730447AbfHAIci (ORCPT + 99 others); Thu, 1 Aug 2019 04:32:38 -0400 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:26982 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730133AbfHAIci (ORCPT ); Thu, 1 Aug 2019 04:32:38 -0400 Received: from localhost.localdomain ([176.167.121.156]) by mwinf5d80 with ME id jkYb2000U3NZnML03kYcJj; Thu, 01 Aug 2019 10:32:36 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 01 Aug 2019 10:32:36 +0200 X-ME-IP: 176.167.121.156 From: Christophe JAILLET To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, allison@lohutok.net, tglx@linutronix.de, clg@kaod.org, groug@kaod.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/2] powerpc/xive: Add a check for memory allocation failure Date: Thu, 1 Aug 2019 10:32:42 +0200 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The result of this kzalloc is not checked. Add a check and corresponding error handling code. Signed-off-by: Christophe JAILLET --- Note that 'xive_irq_bitmap_add()' failures are not handled in 'xive_spapr_init()' I guess that it is not really an issue. This function is _init, so if a memory allocation occures here, it is likely that the system will already be in bad shape. Anyway, the check added here would at least keep the data linked in 'xive_irq_bitmaps' usable. --- arch/powerpc/sysdev/xive/spapr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c index b4f5eb9e0f82..52198131c75e 100644 --- a/arch/powerpc/sysdev/xive/spapr.c +++ b/arch/powerpc/sysdev/xive/spapr.c @@ -53,6 +53,10 @@ static int xive_irq_bitmap_add(int base, int count) xibm->base = base; xibm->count = count; xibm->bitmap = kzalloc(xibm->count, GFP_KERNEL); + if (!xibm->bitmap) { + kfree(xibm); + return -ENOMEM; + } list_add(&xibm->list, &xive_irq_bitmaps); pr_info("Using IRQ range [%x-%x]", xibm->base, -- 2.20.1