From: David Miller <davem@davemloft.net>
To: darrenrjenkins@gmail.com
Cc: inaky.perez-gonzalez@intel.com, linux-wimax@intel.com,
kernel-janitors@vger.kernel.org, cindy.h.kao@intel.com,
dirk.j.brandewie@intel.com, wimax@linuxwimax.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/net/wimax/i2400m/fw.c fix possible double free
Date: Tue, 16 Mar 2010 14:14:45 -0700 (PDT) [thread overview]
Message-ID: <20100316.141445.27416807.davem@davemloft.net> (raw)
In-Reply-To: <1268739988.17270.8.camel@ICE-BOX>
From: Darren Jenkins <darrenrjenkins@gmail.com>
Date: Tue, 16 Mar 2010 22:46:28 +1100
> i2400m_fw_check() can free i2400m->fw_hdrs if krealloc() fails causing a double free
> Add a check so we don't free the memory a second time.
>
> coverity CID: 13455
>
> Signed-off-by: Darren Jenkins <darrenrjenkins@gmail.com>
Please don't fix it like this, the check is obscure and it's
allowing other bugs to happen.
If krealloc() fails, any refrence to i2400m->fw_hdrs is
referencing freed memory.
Therefore the krealloc() failure handling in this driver should NULL
out i2400m->fw_hdrs and that will fix the double kfree problem as well
as trap any stray references.
> ---
> drivers/net/wimax/i2400m/fw.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
> index 25c24f0..a97c413 100644
> --- a/drivers/net/wimax/i2400m/fw.c
> +++ b/drivers/net/wimax/i2400m/fw.c
> @@ -1490,7 +1490,8 @@ int i2400m_fw_bootstrap(struct i2400m *i2400m, const struct firmware *fw,
> if (ret < 0)
> dev_err(dev, "%s: cannot use: %d, skipping\n",
> i2400m->fw_name, ret);
> - kfree(i2400m->fw_hdrs);
> + if (ret != -ENOMEM)
> + kfree(i2400m->fw_hdrs);
> i2400m->fw_hdrs = NULL;
> d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
> return ret;
> --
> 1.6.3.3
next prev parent reply other threads:[~2010-03-16 21:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 11:46 [PATCH] drivers/net/wimax/i2400m/fw.c fix possible double free Darren Jenkins
2010-03-16 21:14 ` David Miller [this message]
2010-03-17 6:05 ` Inaky Perez-Gonzalez
-- strict thread matches above, loose matches on Subject: below --
2010-03-17 12:40 Darren Jenkins
2010-03-17 22:10 ` Inaky Perez-Gonzalez
2010-03-18 8:46 Darren Jenkins
2010-03-20 21:24 ` 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=20100316.141445.27416807.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=cindy.h.kao@intel.com \
--cc=darrenrjenkins@gmail.com \
--cc=dirk.j.brandewie@intel.com \
--cc=inaky.perez-gonzalez@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wimax@intel.com \
--cc=netdev@vger.kernel.org \
--cc=wimax@linuxwimax.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).