netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: netdev@vger.kernel.org
Subject: Potential memory leak in htab_map_update_elem?
Date: Fri, 11 Jan 2019 00:08:04 -0500	[thread overview]
Message-ID: <20190111050804.GB11821@oracle.com> (raw)

Maybe I am missing something trivial here, but it looks to me that there is
a leak of htab elements in htab_map_update_elem when you are updating an
existing element.  After the new element is linked into the bucket list, the
following code snippet is found:

        if (l_old) {
                hlist_nulls_del_rcu(&l_old->hash_node);
                if (!htab_is_prealloc(htab))
                        free_htab_elem(htab, l_old);
        }

Nothing is done with l_old in the remainder of the function, and to me this
looks like that element is be leaked if the htab is preallocated because we
never add it to the free list.  In fact, free_htab_elem() contains the very
conditional that handles the two cases (preallocated vs non-preallocated.

	Cheers,
	Kris

             reply	other threads:[~2019-01-11  5:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11  5:08 Kris Van Hees [this message]
2019-01-11  8:12 ` Potential memory leak in htab_map_update_elem? Daniel Borkmann
2019-01-11 15:20   ` Kris Van Hees

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=20190111050804.GB11821@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).