All of lore.kernel.org
 help / color / mirror / Atom feed
From: arigead@gmail.com (John Whitmore)
To: kernelnewbies@lists.kernelnewbies.org
Subject: staging:rtl8192u: Possible memory leak?
Date: Wed, 26 Sep 2018 16:52:03 +0100	[thread overview]
Message-ID: <20180926155201.GA25719@xux707-tw> (raw)

I've been going through the rtl8192u driver in drivers/staging trying
to get a better understanding of the code. It's possibly not the
text book network driver but it seemed as good a place to start as
any.

So I'm looking at the allocation function in ieee80211_module.c:

struct net_device *alloc_ieee80211(int sizeof_priv)

And can't figure out how there's not a possible memory leak. Either
there is a memory leak or I'm misunderstanding the code. Possibly
the latter is more likely but I thought I'd ask for clarification.

The way I read the function the net_device is allocated with a call
to alloc_etherdev() and if that call fails the code does a
'goto failed'.

If the allocation of the net_device succeeds the funcion
ieee80211_networks_allocate() is called, which allocates an array
of 128 structures. If that allocation fails then again 'goto failed'

That's all fine so far but on line 160 a third allocation is attempted
and again 'goto failed' but ieee80211_network_free(ieee) is never
called to clean up from the call to ieee80211_networks_allocate()

This might all be a mute point as I seem to remember someone saying
that memory allocation never fails in Linux and this can only happen
if the first two allocations work and the third fails.

Still thought I'd ask and possibly learn why I'm wrong, on so many
levels ;)

jwhitmore

             reply	other threads:[~2018-09-26 15:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 15:52 John Whitmore [this message]
2018-09-26 17:52 ` staging:rtl8192u: Possible memory leak? valdis.kletnieks at vt.edu

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=20180926155201.GA25719@xux707-tw \
    --to=arigead@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.