Re: [net-next V8 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP

Yann Ylavic
2017-10-18T10:47:42Z

On Wed, Oct 18, 2017 at 10:38 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> On Wed, 18 Oct 2017 09:45:59 +0200 Yann Ylavic <ylavic.dev@gmail.com> wrote:
>
>> On Mon, Oct 16, 2017 at 12:19 PM, Jesper Dangaard Brouer
>> <brouer@redhat.com> wrote:
>> > +
>> > + /* Notice returns -EPERM on if map size is larger than memlock limit */
>> > + ret = bpf_map_precharge_memlock(cmap->map.pages);
>> > + if (ret) {
>> > + err = ret;
>> > + goto free_cmap;
>> > + }
>> > +
>> > + /* A per cpu bitfield with a bit per possible CPU in map */
>> > + cmap->flush_needed = __alloc_percpu(cpu_map_bitmap_size(attr),
>> > + __alignof__(unsigned long));
>> > + if (!cmap->flush_needed)
>> > + goto free_cmap;
>> > +
>> > + /* Alloc array for possible remote "destination" CPUs */
>> > + cmap->cpu_map = bpf_map_area_alloc(cmap->map.max_entries *
>> > + sizeof(struct bpf_cpu_map_entry *),
>> > + cmap->map.numa_node);
>> > + if (!cmap->cpu_map)
>>
>> ret = -ENOMEM; ?
>
> Did you notice that "err" already is = -ENOMEM at this point?

My bad, I was confused by the use of "ret"...

>
>
>> > + goto free_percpu;
>> > +
>> > + return &cmap->map;
>> > +free_percpu:
>> > + free_percpu(cmap->flush_needed);
>> > +free_cmap:
>> > + kfree(cmap);
>> > + return ERR_PTR(err);

.. while actually "err" is returned.
Sorry for wasting your time.

>> > +}
>>
>>
>> Regards,
>> Yann.