public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox•net>
To: Daniel Mack <daniel@zonque•org>, ast@fb•com
Cc: dh.herrmann@gmail•com, netdev@vger•kernel.org, davem@davemloft•net
Subject: Re: [PATCH v4 1/3] bpf: add a longest prefix match trie map implementation
Date: Mon, 23 Jan 2017 17:39:42 +0100	[thread overview]
Message-ID: <588631CE.9080402@iogearbox.net> (raw)
In-Reply-To: <20170121162613.4159-2-daniel@zonque.org>

On 01/21/2017 05:26 PM, Daniel Mack wrote:
[...]
> +/* Called from syscall or from eBPF program */
> +static int trie_update_elem(struct bpf_map *map,
> +			    void *_key, void *value, u64 flags)
> +{
> +	struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
> +	struct lpm_trie_node *node, *im_node, *new_node = NULL;

im_node is uninitialized here ...

> +	struct lpm_trie_node __rcu **slot;
> +	struct bpf_lpm_trie_key *key = _key;
> +	unsigned long irq_flags;
> +	unsigned int next_bit;
> +	size_t matchlen = 0;
> +	int ret = 0;
> +
> +	if (unlikely(flags > BPF_EXIST))
> +		return -EINVAL;
> +
> +	if (key->prefixlen > trie->max_prefixlen)
> +		return -EINVAL;
> +
> +	raw_spin_lock_irqsave(&trie->lock, irq_flags);
> +
> +	/* Allocate and fill a new node */
> +
> +	if (trie->n_entries == trie->map.max_entries) {
> +		ret = -ENOSPC;
> +		goto out;

... and here we go to out path with ret as non-zero ...

> +	}
> +
> +	new_node = lpm_trie_node_alloc(trie, value);
> +	if (!new_node) {
> +		ret = -ENOMEM;
> +		goto out;
> +	}
[...]
> +
> +out:
> +	if (ret) {
> +		if (new_node)
> +			trie->n_entries--;
> +
> +		kfree(new_node);
> +		kfree(im_node);

... which does kfree() in im_node here.

> +	}
> +
> +	raw_spin_unlock_irqrestore(&trie->lock, irq_flags);
> +
> +	return ret;
> +}

  parent reply	other threads:[~2017-01-23 16:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-21 16:26 [PATCH v4 0/3] bpf: add longest prefix match map Daniel Mack
2017-01-21 16:26 ` [PATCH v4 1/3] bpf: add a longest prefix match trie map implementation Daniel Mack
2017-01-22 22:57   ` Alexei Starovoitov
2017-01-23 16:39   ` Daniel Borkmann [this message]
2017-01-23 16:42     ` Daniel Mack
2017-01-21 16:26 ` [PATCH v4 2/3] bpf: Add tests for the lpm trie map Daniel Mack
2017-01-22 22:58   ` Alexei Starovoitov
2017-01-21 16:26 ` [PATCH v4 3/3] samples/bpf: add lpm-trie benchmark Daniel Mack
2017-01-22 23:02   ` Alexei Starovoitov
2017-01-23 21:11 ` [PATCH v4 0/3] bpf: add longest prefix match map David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=588631CE.9080402@iogearbox.net \
    --to=daniel@iogearbox$(echo .)net \
    --cc=ast@fb$(echo .)com \
    --cc=daniel@zonque$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=dh.herrmann@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox