lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6186fa28-d123-12db-6171-a75cb6e615a5@oracle.com>
Date:   Mon, 28 Sep 2020 15:12:32 -0400
From:   boris.ostrovsky@...cle.com
To:     Dan Williams <dan.j.williams@...el.com>, akpm@...ux-foundation.org
Cc:     Paul Mackerras <paulus@...abs.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Vishal Verma <vishal.l.verma@...el.com>,
        Vivek Goyal <vgoyal@...hat.com>,
        Dave Jiang <dave.jiang@...el.com>,
        Ben Skeggs <bskeggs@...hat.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        Ira Weiny <ira.weiny@...el.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Juergen Gross <jgross@...e.com>,
        Stefano Stabellini <sstabellini@...nel.org>,
        Jérôme Glisse <jglisse@...hat.com>,
        dave.hansen@...ux.intel.com, linux-mm@...ck.org,
        linux-nvdimm@...ts.01.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 10/17] mm/memremap_pages: convert to 'struct range'


On 9/25/20 3:12 PM, Dan Williams wrote:
>  
> diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-alloc.c
> index 3b98dc921426..091b8669eca3 100644
> --- a/drivers/xen/unpopulated-alloc.c
> +++ b/drivers/xen/unpopulated-alloc.c
> @@ -18,27 +18,37 @@ static unsigned int list_count;
>  static int fill_list(unsigned int nr_pages)
>  {
>  	struct dev_pagemap *pgmap;
> +	struct resource *res;
>  	void *vaddr;
>  	unsigned int i, alloc_pages = round_up(nr_pages, PAGES_PER_SECTION);
> -	int ret;
> +	int ret = -ENOMEM;
> +
> +	res = kzalloc(sizeof(*res), GFP_KERNEL);
> +	if (!res)
> +		return -ENOMEM;
>  
>  	pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
>  	if (!pgmap)
> -		return -ENOMEM;
> +		goto err_pgmap;
>  
>  	pgmap->type = MEMORY_DEVICE_GENERIC;


Can you move these last 5 lines ...


> -	pgmap->res.name = "Xen scratch";
> -	pgmap->res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
> +	res->name = "Xen scratch";
> +	res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
>  
> -	ret = allocate_resource(&iomem_resource, &pgmap->res,
> +	ret = allocate_resource(&iomem_resource, res,
>  				alloc_pages * PAGE_SIZE, 0, -1,
>  				PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
>  	if (ret < 0) {
>  		pr_err("Cannot allocate new IOMEM resource\n");
> -		kfree(pgmap);
> -		return ret;
> +		goto err_resource;
>  	}
>  


... here, so that we deal with pgmap in the same place? The diff will be slightly larger but the code will read better I think.


-boris


> +	pgmap->range = (struct range) {
> +		.start = res->start,
> +		.end = res->end,
> +	};
> +	pgmap->owner = res;
> +
>  #ifdef CONFIG_XEN_HAVE_PVMMU
>          /*
>           * memremap will build page tables for the new memory so

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ