Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp64967pxu; Wed, 14 Oct 2020 20:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZrZ2ePXlpk2K0G8UsxEmTrKJOoWDChszBHK9RaDAOaMk8qbh7VdHnwqfVgCJ7t+PR+F5P X-Received: by 2002:aa7:dc16:: with SMTP id b22mr2201370edu.252.1602732482026; Wed, 14 Oct 2020 20:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602732482; cv=none; d=google.com; s=arc-20160816; b=q8ZxdFUbZZv/Up7CePcc3cIzTI/BqjYoN6sD0nXCDmUpA4uWvUaT3+AlBGjjVTkNLE SgIHJWcVHBu7B2nUvLwTdJbdEBFFqOf9mjjNw7OjAbUARZi8NoLaV6hVM/fz473j3FRh LhqClC5ykAbGyey2+XEx9pvWCfmkFzLL6jXqXWk7xwvL/Z2Ful2MHkUpCvRUobKeO27G BiG1NgmXDNviqd6SAw546xGuG6uv7CUP+dDHxdv0oxlNYyZZgzV6kpqhlK2So6wemNQU ZlH4PyV1mM05EIsO88udEC1I4mZrRDya19YGFd0DyfqiZrNEK3v5yfUM5NCU511IJIdv bKkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=F3XipHcWdT3DoA+8Q3rpFljVIbmZbys7QErA+57YNGs=; b=KNtvJxg+OuRU4u4YoJdDdm1sook3RAsVXAzysWZ8d2P9CzmzCdidY4IWqrN5oiMstk atwfWsDcdeyFIAseTEPh+OcBPfzTWY6mIDEu0DNytKlR7HF3Ax/53Z4IWJ9g7nnxN8nt 1k8p8WBtmHzQiBvh732GlKyQR3EPYHBuk5uoirwezYqfbLjSC9bDmL6DfIrlhT/Vf5kl shUmycxGLnjt0mFODkc/8Fs7adTCEf1Zva+8nx15sDEzCIwoDUx56Vhh/s6S4kjcFd5A kfYA6XWbs6CGHLSiYh7jVn+Gw8y7Jnb1cUjbjzhvuX7smXBTNCdGF1zfquTMrjGrGtDY Y4WA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si1399934ejd.238.2020.10.14.20.27.40; Wed, 14 Oct 2020 20:28:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387487AbgJOBAp (ORCPT + 99 others); Wed, 14 Oct 2020 21:00:45 -0400 Received: from mga11.intel.com ([192.55.52.93]:2377 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726684AbgJOBAp (ORCPT ); Wed, 14 Oct 2020 21:00:45 -0400 IronPort-SDR: vWNugVN8vFLWZmHUJKQZLXM3jP+uJWVdWfKR+12XTpjTVTl0LO/Ykdf3YvGAMRnxRl3jRiRD42 9kGLyZkWQ3GQ== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="162764460" X-IronPort-AV: E=Sophos;i="5.77,376,1596524400"; d="scan'208";a="162764460" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 18:00:45 -0700 IronPort-SDR: FfdsxjRqp3q4f4etEQRl1TI5VTynO18vfKev9t2iOTvW0tZxScWrNfuysGf8rx03gz/Y/v7tG4 l/NGqn36Tp+w== X-IronPort-AV: E=Sophos;i="5.77,376,1596524400"; d="scan'208";a="521643942" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 18:00:44 -0700 Subject: [PATCH 2/2] xen/unpopulated-alloc: Consolidate pgmap manipulation From: Dan Williams To: linux-kernel@vger.kernel.org Cc: Juergen Gross , Stefano Stabellini , Andrew Morton , xen-devel@lists.xenproject.org, Boris Ostrovsky , vishal.l.verma@intel.com, dave.hansen@linux.intel.com, akpm@linux-foundation.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org Date: Wed, 14 Oct 2020 17:42:14 -0700 Message-ID: <160272253442.3136502.16683842453317773487.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <160272252400.3136502.13635752844548960833.stgit@dwillia2-desk3.amr.corp.intel.com> References: <160272252400.3136502.13635752844548960833.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cleanup fill_list() to keep all the pgmap manipulations in a single location of the function. Update the exit unwind path accordingly. Link: http://lore.kernel.org/r/6186fa28-d123-12db-6171-a75cb6e615a5@oracle.com Cc: Juergen Gross Cc: Stefano Stabellini Cc: Andrew Morton Cc: Reported-by: Boris Ostrovsky Signed-off-by: Dan Williams --- drivers/xen/unpopulated-alloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-alloc.c index 8c512ea550bb..75ab5de99868 100644 --- a/drivers/xen/unpopulated-alloc.c +++ b/drivers/xen/unpopulated-alloc.c @@ -27,11 +27,6 @@ static int fill_list(unsigned int nr_pages) if (!res) return -ENOMEM; - pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL); - if (!pgmap) - goto err_pgmap; - - pgmap->type = MEMORY_DEVICE_GENERIC; res->name = "Xen scratch"; res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; @@ -43,6 +38,11 @@ static int fill_list(unsigned int nr_pages) goto err_resource; } + pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL); + if (!pgmap) + goto err_pgmap; + + pgmap->type = MEMORY_DEVICE_GENERIC; pgmap->range = (struct range) { .start = res->start, .end = res->end, @@ -91,10 +91,10 @@ static int fill_list(unsigned int nr_pages) return 0; err_memremap: - release_resource(res); -err_resource: kfree(pgmap); err_pgmap: + release_resource(res); +err_resource: kfree(res); return ret; }