From: Dan Carpenter <dan.carpenter@oracle.com>
To: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Linus Walleij <linus.walleij@linaro.org>, linux-gpio@vger.kernel.org
Subject: Re: [bug report] pinctrl: berlin: Don't leak memory if krealloc() fails
Date: Wed, 12 Oct 2016 14:19:24 +0300 [thread overview]
Message-ID: <20161012111924.GJ5630@mwanda> (raw)
In-Reply-To: <20161012094436.3k7abjx64wlyjnyc@linux-x5ow.site>
On Wed, Oct 12, 2016 at 11:44:36AM +0200, Johannes Thumshirn wrote:
> On Wed, Oct 12, 2016 at 11:45:27AM +0300, Dan Carpenter wrote:
> > On Wed, Oct 12, 2016 at 10:30:02AM +0200, Johannes Thumshirn wrote:
> > > Oh I see. Damn, missed the devm_kzalloc(). But shouldn't we avoid krealloc()
> > > on devm_kzalloc() in general? krealloc() calls kfree() if the reallocation
> > > succeeded and this will break the devres tracking, wouldn't it?
> >
> > Good point. I will update my test to check for that.
>
> Well the initial problem still stands, how do we fix the possible double
> free? I think I could "just" change the devm_kzalloc() to kzalloc() (and
> introduce cleanups) but I'm not sure this is a good solution. The whoule point
> of these devm stuff is to apply a safety net, isn't it?
No. It's just a convenience because we allocate so much stuff on probe.
A few people use it like that, where they try to manage their own memory
and use devm_ at the same time and it annoys me.
Just use kzalloc(). But make sure there is a free somewhere.
regards,
dan carpenter
next prev parent reply other threads:[~2016-10-12 11:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 8:14 [bug report] pinctrl: berlin: Don't leak memory if krealloc() fails Dan Carpenter
2016-10-12 8:30 ` Johannes Thumshirn
2016-10-12 8:45 ` Dan Carpenter
2016-10-12 9:44 ` Johannes Thumshirn
2016-10-12 11:19 ` Dan Carpenter [this message]
2016-10-12 12:36 ` Johannes Thumshirn
2016-10-12 17:06 ` Dan Carpenter
2016-10-13 13:09 ` Johannes Thumshirn
2016-10-18 12:34 ` Linus Walleij
2016-10-18 14:12 ` Johannes Thumshirn
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=20161012111924.GJ5630@mwanda \
--to=dan.carpenter@oracle.com \
--cc=jthumshirn@suse.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@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 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.