linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 20:06:40 +0300	[thread overview]
Message-ID: <20161012125846.GK5630@mwanda> (raw)
In-Reply-To: <20161012123616.ff7kiwbsyrnvhwff@linux-x5ow.site>

On Wed, Oct 12, 2016 at 02:36:16PM +0200, Johannes Thumshirn wrote:

> +void berlin_pinctrl_free_funcgroups(struct berlin_pinctrl *pctrl)
> +{
> +	struct berlin_desc_group const *desc_group;
> +	struct berlin_desc_function const *desc_function;
> +	int i;
> +
> +	for (i = 0; i < pctrl->desc->ngroups; i++) {
> +		desc_group = pctrl->desc->groups + i;
> +		desc_function = desc_group->functions;
> +
> +		while (desc_function->name) {
> +			struct berlin_pinctrl_function
> +				*function = pctrl->functions;
> +
> +			kfree(function->groups);

It looks like, we're just freeing pctrl->functions->groups over and
over.

Not taking advantage of managed allocations has made this stuff so much
more complicated.  I'd be tempted almost to just delete the krealloc()
and waste a little RAM...  (I have no idea how much RAM I'm talking
about here so maybe this is a bad idea).

> +			desc_function++;
> +		}
> +	}
> +}
> 

  reply	other threads:[~2016-10-12 17:11 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
2016-10-12 12:36         ` Johannes Thumshirn
2016-10-12 17:06           ` Dan Carpenter [this message]
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=20161012125846.GK5630@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 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).