lkml.org 
[lkml]   [2018]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH v2 1/4] arm64: export memblock_reserve()d regions via /proc/iomem
    From
    Date
    On 06/19/2018 01:44 AM, AKASHI Takahiro wrote:

    > +static int __init reserve_memblock_reserved_regions(void)
    > +{
    > + phys_addr_t start, end, roundup_end = 0;
    > + struct resource *mem, *res;
    > + u64 i;
    > +
    > + for_each_reserved_mem_region(i, &start, &end) {
    > + if (end <= roundup_end)
    > + continue; /* done already */
    > +
    > + start = __pfn_to_phys(PFN_DOWN(start));
    > + end = __pfn_to_phys(PFN_UP(end)) - 1;
    > + roundup_end = end;
    > +
    > + res = kzalloc(sizeof(*res), GFP_ATOMIC);
    > + if (WARN_ON(!res))
    > + return -ENOMEM;
    > + res->start = start;
    > + res->end = end;
    > + res->name = "reserved";
    > + res->flags = IORESOURCE_MEM;
    > +
    > + mem = request_resource_conflict(&iomem_resource, res);
    > + /*
    > + * We expected memblock_reserve() regions to conflict with
    > + * memory created by request_standard_resources().
    > + */
    > + if (WARN_ON_ONCE(!mem))
    > + continue;
    > + kfree(res);

    Why is kfree() after the conditional continue? This is a memory leak.

    > +
    > + reserve_region_with_split(mem, start, end, "reserved");
    > + }
    > +
    > + return 0;
    > +}
    > +arch_initcall(reserve_memblock_reserved_regions);
    > +
    > u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
    >
    > void __init setup_arch(char **cmdline_p)
    >

    \
     
     \ /
      Last update: 2018-06-19 15:39    [W:4.489 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site