From patchwork Fri Jan 31 22:22:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 23993 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F0B24202B2 for ; Fri, 31 Jan 2014 22:22:51 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf12491188pab.9 for ; Fri, 31 Jan 2014 14:22:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=En6uTOSo15mMn6PKBPZlgb4uQ0R1Fm8dtyevxTkKSys=; b=FaDDubIDTqDTiGNOo2AV0OKVP2vTSx1+9eCV5YRqCnIdWUMqYbNGElvqMnVikLrvyH Kmd9Ki6QzO7qT5FPyrivUVooCAmdSxGflqGZF70amwj6tnBtpIXfdgCIoqGMBx9g4IOu ZxzYJ/PHe2FDKy33iRYaboofvEyNVBwfCfAVZcAD5/GhCTrCTeeLUU3SwWsxjQGNAF8I hyARbRaifhKKWn6ockU4RDUqIiBBXS38VDgLVIiW2VRiZvekjzy5PcMe3u1asZeD+p5k 6rRecnvThkovngI2KIXjqDdLsdbaMVfUNXvrxtXzHwXAIlLYJxkloiMQ+HduCWQSaDv7 7xiQ== X-Gm-Message-State: ALoCoQmYKNdf2KhK+0zchngTTNWJI4fvr4gCJjebxRSPVN7T+tLK4H0Ud9STOCKhMcePg5xcniOw X-Received: by 10.66.137.43 with SMTP id qf11mr8481224pab.28.1391206971073; Fri, 31 Jan 2014 14:22:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.73 with SMTP id i67ls1189847qgd.97.gmail; Fri, 31 Jan 2014 14:22:50 -0800 (PST) X-Received: by 10.220.53.66 with SMTP id l2mr6901vcg.33.1391206970830; Fri, 31 Jan 2014 14:22:50 -0800 (PST) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id kl10si4006684vdb.116.2014.01.31.14.22.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Jan 2014 14:22:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.43; Received: by mail-vb0-f43.google.com with SMTP id p5so3294483vbn.2 for ; Fri, 31 Jan 2014 14:22:50 -0800 (PST) X-Received: by 10.220.99.72 with SMTP id t8mr18111635vcn.10.1391206970737; Fri, 31 Jan 2014 14:22:50 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp129913vcz; Fri, 31 Jan 2014 14:22:50 -0800 (PST) X-Received: by 10.14.180.71 with SMTP id i47mr3669793eem.50.1391206969923; Fri, 31 Jan 2014 14:22:49 -0800 (PST) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by mx.google.com with ESMTPS id a9si20600555eem.195.2014.01.31.14.22.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Jan 2014 14:22:49 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.42 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.42; Received: by mail-ee0-f42.google.com with SMTP id b15so734388eek.1 for ; Fri, 31 Jan 2014 14:22:49 -0800 (PST) X-Received: by 10.14.32.132 with SMTP id o4mr27718825eea.14.1391206969483; Fri, 31 Jan 2014 14:22:49 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id k41sm41800544eey.0.2014.01.31.14.22.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Jan 2014 14:22:48 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall Subject: [PATCH] xen/arm: Directly return NULL if Xen fails to allocate domain struct Date: Fri, 31 Jan 2014 22:22:45 +0000 Message-Id: <1391206965-25727-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The current implementation of alloc_domain_struct, dereference the newly allocated pointer even if the allocation has failed. Signed-off-by: Julien Grall --- This is a bug fix for Xen 4.4. Without this patch if Xen run out of memory, it will segfault because it's trying to dereference a NULL pointer. --- xen/arch/arm/domain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 635a9a4..c279a27 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -409,8 +409,10 @@ struct domain *alloc_domain_struct(void) struct domain *d; BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); d = alloc_xenheap_pages(0, 0); - if ( d != NULL ) - clear_page(d); + if ( d == NULL ) + return NULL; + + clear_page(d); d->arch.grant_table_gpfn = xmalloc_array(xen_pfn_t, max_nr_grant_frames); return d; }