Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp907661yba; Thu, 18 Apr 2019 11:35:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIYGDHxhhbovN9bYZmStL2lHO1ya0oFBBmzhKs9eVdMFNBdSXordLC8evEVIcf5eHQL2BN X-Received: by 2002:a17:902:20c9:: with SMTP id v9mr75839850plg.239.1555612513023; Thu, 18 Apr 2019 11:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555612513; cv=none; d=google.com; s=arc-20160816; b=O0w7Ab+vBLGxnyxGCSdASkvP7TaBOhAVkMpcHtspLwwL/OWqRZpCjjoQs+CIt4cnd6 4c+DEOU9QJDI6ZRQOJ79yRcRrglf37ltS5e8+k7HNeomj/nf7avOU8alwflMh51cmV2Q 9+cZoXqGoV4X1OiyeHYN7yNW01Pe0R1R3rHp+scJsQs6hzFduV/O7Ri0uDuscYi5HcEu I90ycala3ohydhUOZ3WU2j5sxcbmOQLXCgrQTcGRCrkd+8Gh4Tbjvvf17dR43pEKIYij q3ORNmRTCi6aPrbSfuRBdZoUKlS8f/wfY/CiKFsSDcFnxzjj2C4e3lLpfWDdTbUOwMZl ZFhA== 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=tjW53rdq+ZQq0uq6pqpYlHJwN7VlVc2Erac7zjaRDzk=; b=slY02kZMovDfNgGvVgliyCAfE4kT1weFN0soPoKGTyCX7oryim2Hxgglh1BV3UvggV g/dl+UUsAudLCdWL0BgZL45cU/M5HmZjYihwHDaLHZtnonYZUtuyisf3KfunZCdt5Q/U V74BAWQ22SFnW4nl/NyjoV4z1+8j4MptvVkxshl4MmeqAqaMn+msB4JJCQnIQEbnBcG1 eAkiIfY1rcK6cYqRj8Ul7ODsGDeAqttHmoRFhX4OH5DfRg8Yh3YYB6Dw5ivULukvqerh IXD24Exkev/llbjmyeFvPZqE53GB1OBYkFEXgzLrmKPKt2Gjx7y6YujlQfWp7uHz2VLB h/yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fHov5Q58; 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 b65si3358790pfg.120.2019.04.18.11.34.57; Thu, 18 Apr 2019 11:35: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=fHov5Q58; 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 S2390210AbfDRSc6 (ORCPT + 99 others); Thu, 18 Apr 2019 14:32:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:54968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389831AbfDRR75 (ORCPT ); Thu, 18 Apr 2019 13:59:57 -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 73DC2206B6; Thu, 18 Apr 2019 17:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610396; bh=j6TqMVgjFtOAJb6ukAQxbmY2WalOjaTfILrGTA7UkpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHov5Q58G55IE9A3uG4ObEh4wP8Q72vhvdQYnqCrWsGMJIiPm3mNRY0toG31VN1qF 5CZlvK8HWXRSq2kdCYM9dieZyjcCvmZYS9iEQpAlQRg7umDZ9rpTFT/puANbFZpUdC AmOLyEkLggCFH7+KZlJ+ETnQq15i9iK2qwXHaEuM= 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 4.19 045/110] x86/hyperv: Prevent potential NULL pointer dereference Date: Thu, 18 Apr 2019 19:56:34 +0200 Message-Id: <20190418160443.128732247@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160437.484158340@linuxfoundation.org> References: <20190418160437.484158340@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 87abd5145cc9..3fb855155286 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -101,9 +101,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