From patchwork Thu May 30 03:05:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10968201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C004912 for ; Thu, 30 May 2019 04:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A36928A3F for ; Thu, 30 May 2019 04:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DC0D28A6D; Thu, 30 May 2019 04:44:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD4AA28A3F for ; Thu, 30 May 2019 04:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729060AbfE3EoZ (ORCPT ); Thu, 30 May 2019 00:44:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727939AbfE3DMC (ORCPT ); Wed, 29 May 2019 23:12:02 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34655244D6; Thu, 30 May 2019 03:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185922; bh=+3kSHClLptg6DesRS/me8pwXtVYyalM2f39uqBqGRao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iyHf5T4u6wMm+gGIyIjslYVp0/sckcuIeLH3NgiCtfUJqnePekTZJFMHlBj1Oa7Wk 3UN3GBsrwq+Vutkl6ThR+XMr6wYTfIFJeLgRInYTygIbPnBwcb1zAvK9TauF5rLXNr 8hrgUsafkpDmCpiRIEhf1zzSDtaNYnOBEhy1+JDs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Borislav Petkov , Andrew Banman , Andy Shevchenko , Colin Ian King , Darren Hart , "Gustavo A. R. Silva" , "H. Peter Anvin" , Ingo Molnar , Kees Cook , Mike Travis , Nicolai Stange , pakki001@umn.edu, platform-driver-x86@vger.kernel.org, Thomas Gleixner , Varsha Rao , x86-ml , Sasha Levin Subject: [PATCH 5.1 310/405] x86/platform/uv: Fix missing checks of kcalloc() return values Date: Wed, 29 May 2019 20:05:08 -0700 Message-Id: <20190530030556.486305232@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.291644921@linuxfoundation.org> References: <20190530030540.291644921@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [ Upstream commit 766460852cfaeca4042e5f3aeb9616b3689147bc ] Handle potential errors returned from kcalloc(). [ bp: rewrite commit message. ] Signed-off-by: Kangjie Lu Signed-off-by: Borislav Petkov Cc: Andrew Banman Cc: Andy Shevchenko Cc: Colin Ian King Cc: Darren Hart Cc: "Gustavo A. R. Silva" Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Kees Cook Cc: Mike Travis Cc: Nicolai Stange Cc: pakki001@umn.edu Cc: platform-driver-x86@vger.kernel.org Cc: Thomas Gleixner Cc: Varsha Rao Cc: x86-ml Link: https://lkml.kernel.org/r/20190325202924.4624-1-kjlu@umn.edu Signed-off-by: Sasha Levin --- arch/x86/platform/uv/tlb_uv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c index 2c53b0f19329a..1297e185b8c8d 100644 --- a/arch/x86/platform/uv/tlb_uv.c +++ b/arch/x86/platform/uv/tlb_uv.c @@ -2133,14 +2133,19 @@ static int __init summarize_uvhub_sockets(int nuvhubs, */ static int __init init_per_cpu(int nuvhubs, int base_part_pnode) { - unsigned char *uvhub_mask; struct uvhub_desc *uvhub_descs; + unsigned char *uvhub_mask = NULL; if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub()) timeout_us = calculate_destination_timeout(); uvhub_descs = kcalloc(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL); + if (!uvhub_descs) + goto fail; + uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); + if (!uvhub_mask) + goto fail; if (get_cpu_topology(base_part_pnode, uvhub_descs, uvhub_mask)) goto fail;