Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp892732yba; Thu, 18 Apr 2019 11:19:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/PGMol8DR+Xib8OmVcsQCaYMmZI2eieVM88UX0GyO/daInvBDKAd5fSQGp8xjiMkJrGRg X-Received: by 2002:a63:4f1c:: with SMTP id d28mr87314643pgb.144.1555611553983; Thu, 18 Apr 2019 11:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611553; cv=none; d=google.com; s=arc-20160816; b=HqVtzoCXwdbuec6bUZj/UJvRPdmQrgK2q8xd49Anb8/UMSbbTl6ssvs0DiC+Bc3mia AAsmuhtI9+3hm7RWvcaLMm6Z+CxJ20hX2gQfTdIX3vxEphyOTZu91RduwHV5v/vhDR/3 87HJL74NfRGFnOKVJsWUcC25KJroihjTVc8JVmMmksKtwJmEpha+JahIZOvQ3zvS4+O0 fBL6HSoFLt2hOg6P8J8dqxIBLvD93Q0CGByUXRYSArEx9NDX7Tj80RxJIS/cX7OuF5Ou Ap+y8DwsSZnbKAEPHz0kJSoyak+ATIekhyldcxLx3SqiQT7TeDgfa/ZsN8ven5qbP5p+ gPFg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kw1W+lJhugwzw+IFNZQBnLVbF9j+ympBbQKCciN7DVs=; b=C5UQQ8Cejsb3fhi+sLzG79eeazTlk8hszWckZO2K3z1x/R6unPPVoo8qoa4r4JHUi/ EAN6zNzyGAwE5wubWSVTSnIOeJaOJjIfnKtxcUZuXNAfvTlD7yXeo8mTI1MKj3nMIqX1 /cTAex4J7FDgONxhKQ2XLWXx/JfOpIt6dugvmyF2DlDvZ20smkSxpL+78STZvcE0NPp8 bDRu06LM0tuRMGHcI4QR4g1uhkjeQg65zVvdatJeUYuqeXSTzyEwrmbVRqKD93EbP1Di 8+fhGSu8qenbeN+9tAfDXXOFvvTepD4LxU2yifMLwF0iOgK7yScjaPvhcjhnfJbEaIg3 TGNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k2ufAqcO; 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 s4si2725111plp.59.2019.04.18.11.18.58; Thu, 18 Apr 2019 11:19:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b=k2ufAqcO; 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 S2391941AbfDRSLl (ORCPT + 99 others); Thu, 18 Apr 2019 14:11:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:43942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391003AbfDRSLk (ORCPT ); Thu, 18 Apr 2019 14:11:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 8D27D206B6; Thu, 18 Apr 2019 18:11:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611099; bh=bukiNlZDJ4xlvhCsv6I/IyCGmRL7YDUBJ/K2kF9g/Ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2ufAqcOCXt4+lEv6/0NO3REVDTACri80EJyfX25KL5AE2kDWNOHbDp9czRJFG15q Lgnjz/RhWzLYJnrzRJq2+wbE03CLnXpPqILp/GNykM9c8Ug6hwWz3OO9eYnCnZEiVN ccbTSGadPkYC/u/2JP2S7gdK1qYuDClIPWjcO3Xc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Thomas Gleixner , Mukesh Ojha , "K. Y. Srinivasan" , pakki001@umn.edu, Haiyang Zhang , Stephen Hemminger , Sasha Levin , Borislav Petkov , "H. Peter Anvin" , linux-hyperv@vger.kernel.org Subject: [PATCH 5.0 57/93] x86/hyperv: Prevent potential NULL pointer dereference Date: Thu, 18 Apr 2019 19:57:35 +0200 Message-Id: <20190418160443.309017791@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 534c89c22e26b183d838294f0937ee092c82ad3a ] The page allocation in hv_cpu_init() can fail, but the code does not have a check for that. Add a check and return -ENOMEM when the allocation fails. [ tglx: Massaged changelog ] Signed-off-by: Kangjie Lu Signed-off-by: Thomas Gleixner Reviewed-by: Mukesh Ojha Acked-by: "K. Y. Srinivasan" Cc: pakki001@umn.edu Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: Sasha Levin Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: linux-hyperv@vger.kernel.org Link: https://lkml.kernel.org/r/20190314054651.1315-1-kjlu@umn.edu Signed-off-by: Sasha Levin --- arch/x86/hyperv/hv_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index d3f42b6bbdac..8a9cff1f129d 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -102,9 +102,13 @@ static int hv_cpu_init(unsigned int cpu) u64 msr_vp_index; struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()]; void **input_arg; + struct page *pg; input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg); - *input_arg = page_address(alloc_page(GFP_KERNEL)); + pg = alloc_page(GFP_KERNEL); + if (unlikely(!pg)) + return -ENOMEM; + *input_arg = page_address(pg); hv_get_vp_index(msr_vp_index); -- 2.19.1