public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Andre Przywara <andre.przywara@arm.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Icenowy Zheng <icenowy@aosc.xyz>,
	Adam Borowski <kilobyte@angband.pl>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chen-Yu Tsai <wens@csie.org>,
	linux-sunxi@googlegroups.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: use non-devm kmalloc versions for free functions
Date: Thu, 4 May 2017 12:00:32 -0400	[thread overview]
Message-ID: <20170504160032.GA5147@htj.duckdns.org> (raw)
In-Reply-To: <20170504120314.lfmcv4cpsuz2igte@lukather>

Hello,

On Thu, May 04, 2017 at 02:03:14PM +0200, Maxime Ripard wrote:
> > @@ -704,6 +704,7 @@ static void pinctrl_generic_free_groups(struct pinctrl_dev *pctldev)
> >  		radix_tree_delete(&pctldev->pin_group_tree, indices[i]);
> >  		devm_kfree(pctldev->dev, group);
> >  	}
> > +	kfree(indices);
> 
> We use devm_kfree for other allocations done here, maybe we can just
> have the same thing here? We would be consistant, and we would still
> keep the resource tracking.

It doesn't make any sense to use the managed functions from the
release functions and if you're always matching devm_kmalloc() with
devm_kfree(), the only thing it'd do is confusing its readers.

And the function in question just looks weird to me - give up on
freeing resources if memory allocation fails?  And why call
devm_kfree() on objects which are being released anyway?  Or if the
group can be released w/o the device being detached, why use devm
allocations on the members at all?

As for removal, can't it just call radix_tree_iter_delete() while
iterating?  Why allocate memory to iterate and store all indices and
to look them up again and delete them?

Thanks.

-- 
tejun

  reply	other threads:[~2017-05-04 16:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 23:57 [PATCH] pinctrl: use non-devm kmalloc versions for free functions Andre Przywara
2017-05-04 12:03 ` Maxime Ripard
2017-05-04 16:00   ` Tejun Heo [this message]
2017-05-05  0:41     ` André Przywara
2017-05-05 19:55     ` Maxime Ripard
2017-05-05 21:49       ` Tejun Heo
2017-05-11 14:01 ` Linus Walleij
2017-05-11 14:02   ` [linux-sunxi] " Icenowy Zheng
2017-05-11 14:20   ` Andre Przywara
2017-05-11 14:45     ` Tejun Heo
2017-05-12  9:25     ` Linus Walleij
2017-05-12 15:35       ` Tony Lindgren
2017-05-12 17:14         ` Tony Lindgren
2017-05-13  0:24           ` André Przywara
2017-05-22 15:37           ` Linus Walleij

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=20170504160032.GA5147@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=icenowy@aosc.xyz \
    --cc=kilobyte@angband.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=wens@csie.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