From patchwork Mon Mar 16 17:30:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11440921 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AF1392A for ; Mon, 16 Mar 2020 17:32:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25C07205ED for ; Mon, 16 Mar 2020 17:32:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="etTnbTHk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25C07205ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jDtaD-0006MV-F7; Mon, 16 Mar 2020 17:31:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jDtaC-0006MQ-Fi for xen-devel@lists.xenproject.org; Mon, 16 Mar 2020 17:31:20 +0000 X-Inumbo-ID: f2598855-67ab-11ea-b872-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f2598855-67ab-11ea-b872-12813bfff9fa; Mon, 16 Mar 2020 17:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zfjUrOmiGlVJcvI2Aj5tCPI4UsPo1GD3QaDUZHh0lZQ=; b=etTnbTHkRPuOWxDsIH73/GDT6m op0iMitgjnkNRRU2+hz8QIfaDiOebvwlf0SFsKxFiF16v0qPtBYH8qIGJWLS5G2Jv1lcXFWJfju0M Ri4RJu+5U35nxb068e0is9I7KsHAIOffyant57Re7uFDvEaOWq87NZcfqzZZc5dE+2/A=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jDtaA-00041Q-Pk; Mon, 16 Mar 2020 17:31:18 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u1bbd043a57dd5a.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jDtaA-00089b-Cm; Mon, 16 Mar 2020 17:31:18 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Date: Mon, 16 Mar 2020 17:30:49 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH] x86/tboot: check return value of dmar_table allocation X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: hx242@xen.org, Wei Liu , Andrew Cooper , Lukasz Hawrylko , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia The allocation can just return NULL. Return an error value early instead of crashing later on. Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- xen/arch/x86/tboot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 8c232270b4..ce85a710dd 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -480,6 +480,8 @@ int __init tboot_parse_dmar_table(acpi_table_handler dmar_handler) sizeof(dmar_table_length), pa + sizeof(char) * ACPI_NAME_SIZE); dmar_table = xmalloc_bytes(dmar_table_length); + if ( !dmar_table ) + return -ENOMEM; tboot_copy_memory(dmar_table, dmar_table_length, pa); clear_fixmap(FIX_TBOOT_MAP_ADDRESS);